Flipkart Interview Experience for SDE Internship | On-Campus (Selected)

Ayushma Sharma
8 min readSep 12, 2021

--

Flipkart recently visited our campus for recruitment of SDE Interns. I am here to share my experience throughout the hiring process.

Eligibility Criteria : Students of CSE and IT were eligible to apply for this position, and there was no CGPA criteria.

Number of Rounds : There were overall 3 rounds conducted. 1 Coding Round and 2 Technical Interviews.

Round 1 (Coding Test) : There were given 3 coding questions to solve within 90 mins.

  • First Question :

The question was based on deque. Two lists of binary codes 0 and 1 were given and the question simply requires to carry operations on the head and rear of the given lists based on some conditions mentioned in the question.

  • Second Question :

The question was to write an algorithm to maximize the salary of a cab driver. The driver has to manage the rides over N calendar days. Each day, he may choose either a ride within a city or an intercity ride. He may also choose to accept no ride. He chooses an intercity ride on days only when he didn’t accept any ride the previous day . The amount for both types of rides vary each day, the charges for intercity ride is always more. We need to calculate the maximum salary that the driver can earn.

Example :

Number of days: 4Charges for city and intercity rides : 10  20
40 100
200 210
20 230
Output: 330
Explanation: To earn maximum salary, the driver must choose intercity rides on second day(100) and fourth day(230).
Thus, maximum salary earned = 100+230 = 330
  • Third Question :

The question was to introduce an image captcha while placing the order to differentiate between real and robotic attempts. Users will get N images showing two random numbers X and Y. The user has to choose the maximum number of images such that the value of X in the first image is less than the value of X in second, similarly the value of Y in the first image is less than the value of Y in the second image and so on. The task was to write an algorithm to identify the maximum number of images that can be selected to match with user output.

Example :

Number of Images, N = 4Count of numbers written on it, C = 2X Y
5 4
6 7
2 3
6 5
Output: 3
Explanation: We can select (2,3), (5,4), (6,5) or (2,3), (5,4),(6,7). So maximum number of images that can be selected is 3.

I used Deque for the first question and Dynamic Programming for second and third question. I was able to solve all the three questions and passed all the test cases. 11 students were shortlisted for the second round.

Round 2 (Technical Interview) :

This round was held on the Codemeet platform. This round started with introduction and he told a bit about how Flipkart works. He asked me 3 questions in this round and it lasted for 45 minutes.

  • First Question :

Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree node values. Null node has tilt 0.

The tilt of the whole tree is defined as the sum of all nodes tilt.

Example :

Input :    4
/ \
2 9
/ \ \
3 5 7
Output : 15Explanation:
Tilt of node 3 : 0
Tilt of node 5 : 0
Tilt of node 7 : 0
Tilt of node 2 : |3-5| = 2
Tilt of node 9 : |0-7| = 7
Tilt of node 4 : |(3+5+2)-(9+7)| = 6
Tilt of binary tree : 0 + 0 + 0 + 2 + 7 + 6 = 15

Approach : Use DFS to recursively traverse the tree and keep track of the sum of subtrees rooted under current node and the tilt of current node. To get the sum of all values in subtree we just need to evaluate s1+s2+node.val where s1 is the sum of nodes of the left subtree and s2 is the sum of nodes of the right subtree.

  • Second Question :

Given an array of employees employees which includes the employee’s unique id, their importance value, and their direct subordinates’ id.

  • employees[i].id is the ID of the employee at index i.
  • employees[i].imp is the importance value of the employee at index i.
  • employees[i].subordinates is a list of the IDs of the subordinates of the employee at index i.

Given an integer id that represents the ID of an employee, return the total importance value of this employee and all their subordinates.

Input: 
employees = [[1,5,[2,3]],[2,6,[]],[3,3,[4]],[4,2,[]]], id = 1
Output: 16Explanation: Employee 1 has importance value 5, and he has two direct subordinates: Employee 2 and Employee 3. They both have importance value 6 and 3. Employee 3 has Employee 4 as direct subordinate with 2 as the importance value.So the total importance value of employee 1 is 5 + 6+ 3 + 2 = 16.

Approach : The idea is to use HashMap for mapping the employees information to their ID and DFS to traverse through all subordinates of the current employee and adding their importance to the final result.

  • Third Question :

Given two arrays of integers, i.e. A and B, find a pair of values by taking one value from each array, such that on swapping the two values, the sum of two arrays become equal. Both the arrays has different number of elements.

Example :

Input:  
A[] = {5, 7, 4, 6}
B[] = {1, 2, 3, 8}
Output: 1
Explanation:
We can swap 6 from array A[] and 2 from array B[]

Approach : I provided two solutions for this question.

  • Naive Approach :

I started with the naive approach, i.e. to iterate through the given arrays and check all pairs of values. Look for a pair of two integers x and y such that :


Sum of A - x + y = Sum of B - y + x
Sum of A - Sum of B = 2x - 2y
(Sum of A - Sum of B)/2 = (x-y)

(Sum of A-Sum of B) / 2 is a target difference target

x-y == target - this simply means that there must exist a pair in order to make the sum of arrays equal.

Time Complexity : O(n*m), where n is the size of array A and m is the size of array B.

  • Optimized Approach :

Then I came up with the optimized solution, i.e. To sort both the arrays and then traversing through both of them simultaneously. For a and b in each pair do the following :

  1. If (a-b) is too small then, make it bigger by moving ‘a’ to a bigger value.
  2. If it is too big, then make it smaller by moving b to a bigger value.
  3. If it is equal to target, then return this pair.

Time Complexity : O(n+m) if the arrays are sorted and O(nlog(n) + mlog(m)) if the arrays are not sorted.

The questions were easy and I successful coded all of them. I discussed the solutions along with their complexities. I also did a dry run for all the questions, and the interviewer was really satisfied by my approach and the code. He told me that I performed well and is going to proceed to the next round.

Around 6 students were shortlisted for the next round.

Round 3 (Technical Interview) :

There were two interviewers in this round and they asked me 2 questions. This round lasted for 50 minutes.

We started by our introduction. He explained his role at Flipkart, and then asked me about the tech stacks I use and my interests. Then we had a talk on full-stack development, specifically, React.js and Node.js because he was also in full-stack development. What are you working on now? Tell me about some project you have worked on and the technologies involved?

  • First Question :

The problem statement was only for discussion. Given an array of strings, the given strings are basically 10 digits phone numbers, and the task is to sort them in ascending order.

Example :

Input : [“9847237492”, “64728103848”, “6748392492”]

Seems too easy, right! But, then he refused me to use any sorting algorithm, no swapping, no comparison. I proposed to use data structures like ordered maps, min heaps, tries. But these data structures also use sorting algorithms internally. He wanted the time complexity of the solution to be O(1). But, there was no limit for space, he told me that I can use any amount of space I want. Then, after discussing a lot and giving many solutions, I came up with a solution which performs sorting using indices of the array. I explained my approach that was taking linear time but extra space. He then helped me in making my solution space-efficient by using Boolean instead of int. He was looking for the same approach and he was satisfied.

Both the interviewers were very friendly and I enjoyed having a discussion with them. I was only asked to share my approach and he was more interested in my thought process.

  • Second Question :

Given a roman numeral, convert it to an integer.

Input:  “CXXVIII”,“IX”, “MCMXCIV”
Output: 128, 9, 1994

Approach : This question is pretty basic. The idea is to use a HashMap to map the conversions of roman numerals to integer. Now, if a numeral with smaller value precedes one with a larger value, we subtract the value from the total, otherwise we add the value to the total. At the end, add the last character value.

Time Complexity: O(n), here n is the length of the string.

He told me to do a dry run of the code for two examples, the code worked fine and we were done with this question.

Finally, it was my chance to ask any questions if I had, I asked a few questions related to his work at Flipkart. He then ended the interview by saying “See you soon” and after sometime I got the email for selection. :)

A total of 3 students were selected for the Flipkart SDE Internship from my campus.

Some Tips to give you an edge :

  1. Be very interactive and confident during the interviews. Show your thought process, discuss various approaches and think out loud all the time (so that even when questions are easy they will catch your thinking with greater importance).
  2. When asked a question, first clarify the question, find edge cases and their expected output and ask for constraints.
  3. Do not directly jump to optimized solution. Always suggest a brute force solution first, then optimize it.
  4. Always tell the time and space complexity of your solution.

You can connect with me on LinkedIn and Twitter.

--

--