Professional Documents
Culture Documents
Report plrn4pf
Report plrn4pf
com
Email: plrn4pf@gmail.com
100% scored in Mock Test in 40 min
Test Name: Mock Test on 25 Mar 2024 22:09:55 IST
195/195
Taken On: 25 Mar 2024 22:09:55 IST
Skills Score:
Core CS 195/195
Easy 105/105
Greedy Algorithms 90/90
Medium 90/90
Problem Solving 195/195
Search 105/105
Sorting 105/105
problem-solving 195/195
Recruiter/Team Comments:
No Comments.
Problem Solving
Correct Answer
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/5
The sorted array . The middle element and the median is .
Function Description
Returns
int: the median of the array
Input Format
Constraints
is odd
Sample Input 0
7
0 1 2 4 6 5 3
Sample Output 0
Explanation 0
CANDIDATE ANSWER
1
2 /*
3 * Complete the 'findMedian' function below.
4 *
5 * The function is expected to return an INTEGER.
6 * The function accepts INTEGER_ARRAY arr as parameter.
7 */
8
9 function findMedian(arr) {
10 var sortedArr = arr.sort((a,b) => a-b)
11
12 return sortedArr[(sortedArr.length-1)/2]
13
14 }
15
2/5
Testcase 4 Easy Hidden case Success 35 0.0846 sec 56.3 KB
estcase asy dde case Success 35 0 08 6 sec 56 3
No Comments
QUESTION DESCRIPTION
Score 90
Sean invented a game involving a matrix where each cell of the matrix contains an integer. He
can reverse any of its rows or columns any number of times. The goal of the game is to maximize the sum
of the elements in the submatrix located in the upper-left quadrant of the matrix.
Given the initial configurations for matrices, help Sean reverse the rows and columns of each matrix in the
best possible way so that the sum of the elements in the matrix's upper-left quadrant is maximal.
Example
1 2
3 4
It is and we want to maximize the top left quadrant, a matrix. Reverse row :
1 2
4 3
4 2
1 3
Function Description
Returns
- int: the maximum sum possible.
Input Format
Constraints
, where .
Sample Input
3/5
STDIN Function
----- --------
1 q = 1
2 n = 2
112 42 83 119 matrix = [[112, 42, 83, 119], [56, 125, 56, 49], \
56 125 56 49 [15, 78, 101, 43], [62, 98, 114, 108]]
15 78 101 43
62 98 114 108
Sample Output
414
Explanation
Perform the following operations to maximize the sum of the submatrix in the upper-left quadrant:
2. Reverse column ( ), resulting in the matrix:
CANDIDATE ANSWER
1
2 /*
3 * Complete the 'flippingMatrix' function below.
4 *
5 * The function is expected to return an INTEGER.
6 * The function accepts 2D_INTEGER_ARRAY matrix as parameter.
7 */
8
9 function flippingMatrix(matrix) {
10 var sum =0
11 for(let i=0; i< matrix.length/2;i++){
12 for(let j = 0; j< matrix[0].length/2;j++)
13 sum+= Math.max(matrix[i][j], matrix[i][matrix[0].length-j-1],matrix[
14 matrix.length- i-1][j],matrix[ matrix.length- i-1][matrix[0].length-j-1])
15 }
4/5
16
17 return sum
18
19 }
No Comments
5/5