3 DSA questions, 90 minutes 2 easy-ish mediums, 1 hard-ish medium.
Question 1 (the easy one) ; simple array manipulation where brute force passed all the testcases.
Question 2;
given an integer N and K. divide an array containing numbers from [1,n] into k segments such that difference between max(segments) and min(segments) is at most 1.
it is given that k is always even and 2 <= k <=n.
Example 1 :
N = 2, K = 2
output : {1,2}; here the segments are {1} and {2}
Example 2 :
N = 7, K = 4
output : {1,7,3,5,2,6,4}; here the segments are [1,7,3,5] and [7,3,5,2] and [3,5,2,6] and [5,2,6,4]. max(segments) = 17, min(segments) = 16.
Question 3;
int N represents the number of students in a class, vector of int chairs is given where chairs[i] = chair the i'th student wants to sit in. Students are alloted chairs one after another, (student 1 is alloted a chair first, then student 2 and so on). A student tries to sit on his/her preferred chair, If the chair is filled, the student moves to the next empty chair. If the last chair is filled then the student moves to the first chair of the list and resumes his/her search for an empty chair. return the chair numbers in the order they are filled
Example; number of students = 3, chairs = {2,2,2}.
output : {2, 3, 1}
student 1 sits on his preferred chair 2. student 2 tries to sit on chair 2 but it is occupied so he sits on the next chair, chair 3. student 3 tries chair 2, then chair 3, then loops back and tries chair 1 which is empty.
Example: number of students = 1, chairs = {1}
output = {1};
Edit : The round was held for about 100 students, of which 8 moved ahead to the next round. Only the ones that solved all three were allowed to continue in the process.


