0% found this document useful (0 votes)
56 views3 pages

MERN Assessment 2023

Uploaded by

Akansha Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

MERN Assessment 2023

Uploaded by

Akansha Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

––

ASSESSMENT
TEST 2023

MERN
Problem Solving Question:
Write a function shuffle(arr)that takes input an array of numbers and returns an array by ordering the
numbers in following fashion:
a1 <= a2 >= a3 <= a4 >= ....
Please note that there are multiple outputs that are possible for a given array. Your function can return
one possible output.
Example: If input is [2, 1, 5, 3, 11, 7], one possible output could be [2, 7, 3, 11, 1, 5]

Once you are done, please respond back with following details:

Description Response

URL that contains the solution in


Javascript or Typescript. Approach 1 Implementation:
https://codeshare.io/EB7mlv
1. Go to: https://codecollab.io
(or any other editor of your Approach 2 Implementation:
choice) https://codeshare.io/X83z3l
2. Write your code (ensure it
runs successfully)
3. Share the link of the URL
Time complexity (Big O notation) of your
solution Approach 1: O(N * logN)
Approach 2: O(N)

Where N denotes the size of the array


Space complexity (Big O notation) of
your solution Approach 1: O(N)
Approach 2: O(1)

List all possible test cases


Test Case 1:
Input: [ 2, 3, 1, 4, 2 ]
Output: [ 3, 1, 4, 2, 2 ]

One possible output array is


[ 3, 1, 4, 2, 2 ]

Test Case 2:
Input: [8, 1, 3, 4, 5.5, -7, -1]
Output: [8, 1, 4, 3, 5.5, -7, -1]

One possible output array is


[8, 1, 4, 3, 5.5, -7, -1]

Test Case 3:
Input: [ 4, 3, 2, 5, 4, 1]
Output: [ 4, 2, 5, 3, 4, 1 ]
One possible output array is
[ 4, 2, 5, 3, 4, 1 ]

Test Case 4:
Input: [2, -1, 3.3, 4, 1, 5, -8, 1]
Output: [2, -1, 4, 1, 5, -8, 3.3, 1]

Please make a copy of this document (under File -> Make a copy) instead of requesting edit
access to this document.

You might also like