Panda Guru LogoPanda
Guru

Flipkart sde-1 oncampus round 1, october 2024

Round 1

Questions:

  1. Question 1: Simple array manipulation where brute force passed all the test cases.

  2. Question 2: Given an integer N and K, divide an array containing numbers from [1, N] into K segments such that the 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], [7, 3, 5, 2], [3, 5, 2, 6], and [5, 2, 6, 4]. max(segments) = 17, min(segments) = 16.
  3. 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 allotted chairs one after another. 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, 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 chair 2, student 2 moves to chair 3, student 3 loops back and sits on chair 1.
    • Example:
      • Number of students = 1, chairs = {1}.
      • Output: {1}.
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.