SWIGGY ALL INTERVIEW QUESTIONS
- Result
- Ongoing
- Posted
- 1 Sept 2022
Summary
I have compiled a comprehensive list of interview questions encountered during Swiggy's onsite interviews for both SDE-1 and SDE-2 roles, covering a wide range of LeetCode problems and system design challenges.
How it went
I've gathered these interview questions from various Swiggy SDE-1 and SDE-2 onsite rounds. This collection provides insights into the types of problems asked, encompassing classic data structures and algorithms, with direct references to many LeetCode problems, as well as several conceptual and system design questions. It serves as a valuable resource for anyone preparing for technical interviews at Swiggy.
Questions asked (24)
- 01
Rotting Oranges (Similar)
Data Structures & Algorithms · Medium
Open the problemA problem similar to Rotting Oranges, which typically involves a grid of fresh, rotten, and empty oranges. Fresh oranges rot if adjacent to a rotten orange. The goal is to find the minimum time until all fresh oranges rot or if it's impossible for all fresh oranges to rot.
- 02
Find the Duplicate Number
Data Structures & Algorithms · Medium
Open the problemGiven an array
numscontainingn + 1integers where each integer is between1andn(inclusive). Prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. The interviewer specifically looked for an O(1) space complexity solution. - 03
Nth Recently Used Number in Stream
Data Structures & Algorithms
Given a stream of numbers, find the nth most recently recurring number. For example, if the stream is
[1, 1, 2, 3, 2, 4]andn = 2, the output should be the 2nd most recently recurring number. This problem implies tracking both frequency and recency of numbers in a stream. - 04
Group Anagrams
Data Structures & Algorithms · Medium
Open the problemGiven an array of strings
strs, group the anagrams together. You can return the answer in any order. - 05
Merge k Sorted Lists
Data Structures & Algorithms · Hard
Open the problemYou are given an array of
klinked-lists, each sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. - 06
Course Schedule II (Modified)
Data Structures & Algorithms · Medium
Open the problemA problem with a slight modification based on Course Schedule II. The original problem asks to return the ordering of courses you should take to finish all courses, or an empty array if it's impossible. The core problem involves topological sorting.
- 07
Subarray Sum Equals K (Modified)
Data Structures & Algorithms · Medium
Open the problemA modified version of the Subarray Sum Equals K problem. The original problem asks to find the total number of continuous subarrays whose sum equals
k. - 08
Subarray Sums Divisible by K
Data Structures & Algorithms · Medium
Open the problemGiven an integer array
numsand an integerk, return the number of non-empty subarrays that have a sum divisible byk. - 09
Lowest Common Ancestor of a Binary Tree
Data Structures & Algorithms · Medium
Open the problemGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
- 10
Alien Dictionary
Data Structures & Algorithms · Hard
Open the problemThere is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of
wordsfrom the alien language's dictionary, where the words are sorted lexicographically by the rules of this new language. Derive the order of the letters in this language. - 11
Building Bridges
Data Structures & Algorithms · Hard
This problem typically involves finding the maximum number of non-crossing bridges that can be built between two banks of a river, given coordinates for cities on both banks. It's a classic dynamic programming problem, often solved using a variation of the Longest Increasing Subsequence algorithm.
- 12
Design LRU Cache
System Design · Medium
Open the problemDesign a Least Recently Used (LRU) cache. Implement the
LRUCacheclass:LRUCache(int capacity)initializes the LRU cache with positive sizecapacity.int get(int key)returns the value of the key if the key exists, otherwise returns -1.void put(int key, int value)updates the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds thecapacityfrom this operation, evict the least recently used key. - 13
Coin Change (Similar)
Data Structures & Algorithms · Medium
Open the problemA problem similar to the Coin Change problem. The standard Coin Change problem asks for the fewest number of coins needed to make up a certain amount, or the number of combinations of coins that sum up to a given amount.
- 14
Surrounded Regions
Data Structures & Algorithms · Medium
Open the problemGiven an
m x nmatrixboardcontaining'X'and'O', capture all regions that are 4-directionally surrounded by'X'. A region is captured by flipping all'O's into'X's in that surrounded region. Regions touching the border are not considered surrounded. - 15
Maximum Length of Pair Chain
Data Structures & Algorithms · Medium
Open the problemYou are given
npairs of numbers,pairs[i] = [starti, endi]. A pair(c, d)follows a pair(a, b)ifb < c. A chain of pairs can be formed in this fashion. Return the length of the longest chain which can be formed. - 16
Find All Greater Numbers Formed by Digits
Data Structures & Algorithms · Medium
Given a number, find all possible numbers that can be formed using its digits which are greater than the given number. For example, if the input is
213, the output should include231, 312, 321. This typically involves generating permutations. - 17
Nearest Node Value in Binary Tree
Data Structures & Algorithms · Easy
Given a binary tree and a target value, find the node value in the tree that is closest to the target value.
- 18
String Replacement with Mismatched Substrings
Data Structures & Algorithms · Medium
Open the problemGiven a string
S, a source arraysource, a target arraytarget, and an index arrayindices. For eachi, if the substring ofSstarting atindices[i]matchessource[i], then replace that substring withtarget[i]. Otherwise, do nothing. Replacements are independent and should be performed simultaneously. - 19
Game on Circular Array (Maximizing Score)
Data Structures & Algorithms · Hard
Two players take turns picking one element from either end of a circular array. The goal for each player is to maximize their own score. The problem asks to find the maximum possible gain for the first player and determine if the first player always wins.
- 20
Palindrome Pairs
Data Structures & Algorithms · Hard
Open the problemGiven a list of unique words, return all the pairs of distinct indices
(i, j)in the given list, so that the concatenation of the two wordswords[i] + words[j]is a palindrome. - 21
Climbing Stairs
Data Structures & Algorithms · Easy
Open the problemYou are climbing a staircase. It takes
nsteps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? - 22
Jump Game III
Data Structures & Algorithms · Medium
Open the problemGiven an array of non-negative integers
arrand a start indexstart. You are initially atstart. When you are at indexi, you can jump toi + arr[i]ori - arr[i]. Can you reach any index with value 0? - 23
Jump Game II
Data Structures & Algorithms · Medium
Open the problemGiven an array of non-negative integers
nums, you are initially positioned at the first index. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. - 24
Longest Substring Without Repeating Characters
Data Structures & Algorithms · Medium
Open the problemGiven a string
s, find the length of the longest substring without repeating characters.