Flipkart DSA Questions | Compiled
Summary
This post provides a compiled list of Data Structures and Algorithms questions frequently encountered or asked in Flipkart's interview processes, particularly focusing on the DSA round.
Full Experience
DSA Round (60 mins)
- 2 Questions (Medium level)
- 45 mins to solve
- 15 mins for Introduction & Q/A
Areas to focus on:
- Time Complexity understanding
- Edge Cases
- Choice of best data structure.
- Be verbose, keep it interactive.
Interview Questions (13)
Add Two Numbers
Given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
LRU Cache
Design and implement a data structure for a Least Recently Used (LRU) cache. It should support the following operations: get and put.
Binary Tree Right Side View
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Map with Prefix Sum
Design a map that allows you to do the following: Maps a string key to a given value. void insert(string key, int val): Inserts the key-val pair into the map. If the key already existed, the original key-value pair will be overridden to the new one. Int sum(string prefix): Returns the sum of the values that have a key with a prefix equal to a given string. There is an initialize() method, in case you want to initialize any internal data structure of your map.
Maximize Minimum Magnetic Force
You have “n” empty baskets, you are given the position of the empty baskets in an array called "position", where position[i] specifies the position of the ith basket. Additionally you have m balls to be distributed among the n baskets, You have to distribute the m balls into n baskets such that the minimum magnetic force between any two balls is maximum. The magnetic force between two different balls at position x and y is defined as |x-y|.
Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Sliding Window Maximum
Print the maximum element from every k consecutive elements in an array of size n. Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Return the maximum sliding window.
Count Subarrays with At Most K Distinct Elements
Given an integer array, print the count of subarrays which had atmost k distinct elements. Given an integer array nums and an integer k, return the number of subarrays that have at most k distinct elements.
Minimum Operations to Reduce Number to Zero by Subtracting Digits
Given a number, find the minimum no of operations done to reduce the number to zero. An operation is defined as subtracting one of the digits from the number.
Rotting Oranges
You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no fresh oranges are present. If this is impossible, return -1.
Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
Longest Substring Without Repeating Characters
Given a string s, find the length of the longest substring without repeating characters.
Minimum Time to Propagate Information in N-ary Tree
Minimum time required to propagate the information from root to all child nodes of n-ary tree where in one path, the information can only be propagated at one level and other levels will need to wait.
Preparation Tips
Other Rounds
Check Flipkart Tech blog
Medium articles
Topics to cover
- Binary Search
- Priority Queue (Min Heap and Max Heap)
- Array
- Trees (BFS)