

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Flipkart Study Guide
Typology: Exercises
1 / 33
This page cannot be seen from the preview
Don't miss anything!


























Index
A Typical interview process for Software Development Engineer is divided into 4 rounds
Sample Questions
1 - Given a mxn grid, each of its element be either โ.โ, โRโ, โGโ or โBโ, where โ.โ - > empty, โRโ - > Red, โGโ - > Green, โBโ - > Blue A Blue strip has width 1 and length greater or equal to one. A Red strip has length 1 and width greater or equal to one. If a Red strip and a Blue strip overlaps, the overlapped portion will become โGโ. Find the minimum number of strips required to cover the whole grid. 1<= m,n <= Ex. Input 2 4 ..B. ..B. Output 1 Explanation: Blue strips are vertical. Red strips are horizontal. Ex 1: Only 1 vertical strip from (0,2) to (1,2). [Indexing from (0,0)] Ex 2: 1 vertical strip from (0,2) to (2,2) 1 horizontal strip from (1,2) to (1,4) 1 horizontal strip from (3,0) to (3,0) 1 horizontal strip from (4,0) to (4,0) so total โ 4 Input 5 5 ..B.. ..GRR ..B.. R.... R.... Output 4 Input 5 5 ..B.. ..GRR ..B.. B.... B...G Output 5
Sample Questions
Example: For the graph in diagram, A dependencies: C,D i.e. 2 B dependencies: D i.e. 1 C dependencies: D i.e. 1 And D depends on none. Hence answer=0+1+1+2=4. 5 - At Flipkart, an employee has many subordinates. But an employee can also have many managers. And a manager can further have more managers overseeing his work. A simple "boss-employee-relationship- can be denoted by an arrow '-->' A --> B --> C This denotes that A is direct boss of B, who is direct boss of C. Here A is also (indirect) boss of C. It is guaranteed that there is no cycles in this relationship. That is there exists no pair of employees, X and Y, such that X is boss of Y and Y is also boss of X. The salary of an employee can be calculated on the basis of following rules:
Sample Questions
"relations" denotes a array of strings, where if the jth character of ith^ string is Y, if employee i is a direct boss of employee j. Otherwise it is "N". You have to display the sum of salaries of all employees. Complete this function in the code editor int Summing(String[] relations) Constraints The size of relations array will not have elements greater than 50. the arrays will only contain string composed of "Y" & "N" each element of the array has same number of characters For k th row. the k th element will always be "N" If X is boss of Y. Y cannot be a boss or X. Test cases are designed such that answers will always lie within the range of signed 32bit int. Sample Case # Input Returns: 1 Explanation: There is only one employee, so his salary will be 1. Sample Case # Input NNYN NNYN NNNN NYYN Returns: 5 Explanation: It has the following relation. 4 |
1 | 2 \ | / 3 So salary of 3rd employee is 1, 1st and 2nd employee is equal to the sum of its (only) employee (3rd) which is 1. Salary of 4th employee is sum of salary of 2nd and 3rd employee which is 1 + 1 2. So total salary is 2 + 1
Sample Questions
6 - A person wants to go from origin to a particular location, he can move in only 4 directions(i.e East, West, North, South) but his friend gave him a long route, help a person to find minimum Moves so that he can reach to the destination. Input โ NESNWES Output โ E You need to print the lexicographically sorted string. Assume the string will have only โEโ โNโ โSโ โWโ characters. E.g. โ SSSNEEEW output โ EESS 7 - A sender will send a binary string to a receiver meanwhile he encrypt the digits. You are given a encrypted form of string. Now, the receiver needs to decode the string, and while decoding there were 2 approaches. First, receiver will start with first character as 0; S[0] = 0, P[1] = S[1] + S[0], P[2] = S[2] + S[1] + S[0] and so on. Second, Receiver will start with first character as 1; S[0] = 1, P[1] = S[1] + S[0], P[2] = S[2] + S[1] + S[0] and so on. You need to print both the strings, after evaluation from both first and second technique. If any string will contain other that binary numbers you need to print NONE. Input1; 0123210 Output: 0111000 NONE explanation for NONE โ S[0] = 1, P[1] = S[1] + S[0] so S[1] = 0 P[2] = s[2] + S[1] + S[0] , S[2] = 1 P[3] = S[3] + S[2] + S[1], S[3] = 2, not a binary character so NONE
Sample Questions
8 - Main DNA sequence(a string) is given (let say strDNA) and another string to search for(let say strPat). You have to find the minimum length window in strDNA where strPat is subsequence. 9 - There is a zoo and there are several groups (number of groups:K) of people for tour. Each group is having different size (g1,g2,g3โฆgK). There is one bus with capacity C. Journey starts from a point and bus will come back to the same point. A group can only be included in the bus if all the members of the groups can be accumulated in bus. After coming back from the tour, each group in the bus will again wait in the queue at the bus-stand. Bus-driver earns a rupee for each person travelled. You have to find the earning of the bus driver after R rounds. For example : Number of groups G = 4 Group size for each group : 2 4 3 5 Bus capacity : 7 Number of rounds R : 4 queue : (from front side) 2 4 3 5 First round : 2 4 (we canโt take 3rd group as 3 members canโt be accumulated after 2 and 4.) queue : 3 5 2 4 (1st and 2nd group are enqueued. i.e. 2 and
Second round : 3 queue : 5 2 4 3 Third Round : 5 2 queue : 4 3 5 2 Fourth Round : 4 3 After 4 rounds, total earning is 6+3+7+7 = 23.
Sample Questions
1 - Find the square root of a given integer. e.g. 27 output should be 5, for 32 output should be 6. 2 - Given a 2D matrix of integers find the maximum sum path in the matrix. 3 - Solve Snakes and ladder problem, Given all the inputs for the board. You can roll the dice, as you want to. Need to find the shortest path to reach the 100 level from the starting of the path. 4 - Given a file with millions of words, need to find top K words on the basis of occurrence 5 - Print the left view of a tree. 6 - Given set of words that are lexographically sorted, find the grammar. E.g.: abc acd bcc bed bdc dab The order of letters for the given example would be a->b->c->e->d 7 - Generate all numbers in ascending order which are having factors as 2,3 and 5. Discuss various approaches. 8 - Check whether given Binary Tree is a Binary Search Tree. Discuss various approaches. 9 - Given an array of n distinct integers sorted in ascending order. Find an index i s.t ar[i] = i. Return - 1 if no such index exists. Note that integers in array can be negative. 10 - Design a stack which holds an integer value such that getMinimum() function should return the minimum element in the stack.
Sample Questions
FOLLOW UP: Implement popMin() function which would pop minimum element from the original stack. O(1) implementation was required.(Hint: Use Linked List to implement stack and store address of minimum element node in min-stack) 11 - Print an organizational hierarchy. Naveen manages Satish Satish manages Anushree Satish manages Sandeep Gurinder manages Naveen Gurinder->Naveen Naveen->Satish Satish->Anushree,Sandeep Anushree-> Sandeep->
Sample Questions
9 - In a client-server architecture, there are multiple requests from multiple clients to the server. The server should maintain the response times of all the requests in the previous hour. What data structure and algorithm will be used for this? Also, the average response time needs to be maintained and has to be retrieved in O(1). 10 - Given N meetings with their start time s1, s2 โฆ.sn and end time e1, e2 โฆ.en and K rooms. How to schedule maximum of N meetings in k rooms. 11 - Given an array which is first strictly increasing and then strictly decreasing. Find an element in this array.
Sample Questions
1 - You are given a sorted array of size 7 but only 4 elements in it and a sorted array of 3 elements. How would to combine the elements into the first array in such a way that array is sorted. 2 - How do you find if a string is a palindrome or not? 3 - Given a corrupted string i.e. its original string with just the spaces at wrong places, Construct the original string .You are given a dictionary of words. Ex:- string : Com put erengineering original string: Computer Engineering 4 - Given a lane where there are various houses each containing a fixed amount of gold. Now a robber has to rob the houses such that when he robs a house the adjacent one cannot be robbed. Calculate the maximum amount of gold collected by him. 5 - Given 1000 elephant ,none of whom exact heights are known, there are statements given which will be of two forms 3.i-E_i is taller than E_j OR 3.ii-E_i is smaller than E_j Calculate the ascending order of the elephants(in terms of height). 6 - Topologically sort the DAG(excluding forest arrangement) given if the source is not known. For Ex: if edges are 1->2,1->3,2->4,3->.
Sample Questions
Sample Questions
11 - Write code to parse an XML and do the following options by not hardcoding any value.