You are on page 1of 3

Mock Test  nimishsrivastava01527@gmail.

com

Full Name: Nimish Srivastava

Email: nimishsrivastava01527@gmail.com scored in Mock Test in 1 min 50


100% sec on 18 Jun 2023 11:09:53
Test Name: Mock Test
IST
105/105
Taken On: 18 Jun 2023 11:09:53 IST

Time Taken: 1 min 50 sec/ 10 min

Invited by: Ankush

Invited on: 18 Jun 2023 11:09:41 IST

Skills Score:

Tags Score: Algorithms 105/105


Core CS 105/105

Easy 105/105

Problem Solving 105/105


Search 105/105

Sorting 105/105
problem-solving 105/105

Recruiter/Team Comments:

No Comments.

Plagiarism flagged

We have marked questions with suspected plagiarism below. Please review it in detail here -

Question Description Time Taken Score Status

Q1 Find the Median  Coding 1 min 31 sec 105/ 105 

QUESTION 1 Find the Median 



Coding Sorting Search Algorithms Easy problem-solving Core CS

Problem Solving
Needs Review

QUESTION DESCRIPTION
Score 105

The median of a list of numbers is essentially its middle element after sorting. The same number of
elements occur after it as before. Given a list of numbers with an odd number of elements, find the median?

Example

1/3
The sorted array . The middle element and the median is .

Function Description

Complete the findMedian function in the editor below.

findMedian has the following parameter(s):


int arr[n]: an unsorted array of integers

Returns
int: the median of the array
Input Format

The first line contains the integer , the size of .


The second line contains space-separated integers

Constraints

is odd

Sample Input 0

7
0 1 2 4 6 5 3

Sample Output 0

Explanation 0

The sorted . It's middle element is at .

CANDIDATE ANSWER

Language used: C++

1 #include <cmath>
2 #include <cstdio>
3 #include <vector>
4 #include <iostream>
5 #include <algorithm>
6 using namespace std;
7
8
9 int main() {
10
11 int n, *arr;
12 cin>>n;
13 arr = new int[n];
14 for (int i = 0 ; i < n ; i++) cin>>arr[i];
15 sort(arr,arr+n);
16 if (n%2 == 1) cout<<arr[(n-1)/2]<<endl;
17 else cout<<(arr[n/2 - 1]+arr[n/2])/2<<endl;
18 return 0;
19 }
20
21
22
23
24

2/3
25
26
27

TESTCASE DIFFICULTY TYPE STATUS SCORE TIME TAKEN MEMORY USED

Testcase 1 Easy Sample case  Success 0 0.0556 sec 8.84 KB

Testcase 2 Easy Hidden case  Success 35 0.0441 sec 8.87 KB

Testcase 3 Easy Hidden case  Success 35 0.0371 sec 8.84 KB

Testcase 4 Easy Hidden case  Success 35 0.0387 sec 9.18 KB

No Comments

PDF generated at: 18 Jun 2023 05:43:26 UTC

3/3

You might also like