SWIGGY ONSITE INTERVIEW QUESTIONS (SDE-1,SDE-2)
Question: similar to https://leetcode.com/problems/rotting-oranges/
Discussed about a DS & Algo question related to parking lot system.
https://leetcode.com/problems/find-the-duplicate-number/, I gave approach 1 (sorting) & approach 2 (using map) to the interviewer but he didn't seem satisfied since he wanted me to solve it in O(1) space complexity (approach 3) of the solution - Floyd's Tortoise and Hare (Cycle Detection)
Given a stream of numbers, find nth recurring recently used number.
Example - [1, 1, 2, 3, 2, 4] Suppose n = 2
little modification ( https://leetcode.com/problems/course-schedule-ii/ )
Modified ( https://leetcode.com/problems/subarray-sum-equals-k/ )
Find the Lowest common ancestor of binary tree : https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
Find the Lowest common ancestor of binary tree : https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
Alien Dictionary problem : https://leetcode.com/problems/alien-dictionary/
Building Bridges problem : https://www.g***org/dynamic-programming-building-bridges/
Design LRU cache. First I gave the most brute design, then I optimzed it.
Similar to coin change problem - Solved completely
Question 1: https://leetcode.com/problems/surrounded-regions/
Question 2: https://leetcode.com/problems/maximum-length-of-pair-chain/
Given a number find all greater numbers formed by the digits. For ex: input 213, output: 231, 312, 321
Given a Target, find nearest node value present in Tree.
Given a string, a source array, target array and index array, replace index[i]th from substrng from given string, if substring of given string matches source[i] to target[i]. Else ignore.
Find the maximum gain in a two-players game where a circular array is given and each player in turn is allowed to pick one element from either end of the array. The goal of each player is to score more than his opponent. Does the player who plays first always win?
Longest substring with non repeating characters
Will add more !