All programs are categorized in level 1 to 4 (1 being easiest)
- Bubble sort (Python): Implement bubble sort in Python | O(n^2) | Level 2.
- Bubble sort (Go): Implement bubble sort in Golang | O(n^2) | Level 2.
- Selection sort (Python): Implement selection sort in Python | O(n^2) | Level 2.
- Selection sort (Go): Implement selection sort in Golang | O(n^2) | Level 2.
- Insertion sort (Python): Implement insertion sort in Python | O(n^2) | Level 2.
- Insertion sort (Go): Implement insertion sort in Golang | O(n^2) | Level 2.
- Heap sort using max heap (C): Build a max heap and sort array in ascending order in C | Level 3.
- Heap sort using max heap (Python): Build a max heap and sort array in ascending order in Python | Level 3.
- Heap sort using max heap (Go): Build a max heap and sort array in ascending order in Golang | Level 3.
- Heap sort using min heap (C): Build a min heap and sort array in descending order in C | Level 3.
- Heap sort using min heap (Python): Build a min heap and sort array in descending order in Python | Level 3.
- Heap sort using min heap (Go): Build a min heap and sort array in descending order in Golang | Level 3.
- Merge sort: Implement merge sort | O(nlogn) | Level 3.
- Merge sort - python: Implement merge sort in python | O(nlogn) | Level 3.
- Quick sort: Implement quick sort(C) for array of random numbers | O(nlogn) | Level 3.
- Quick sort - python: Implement quick sort(python) for array of random numbers | O(nlogn) | Level 3.
- Counting sort: Implement count sort | O(n + k) | Level 2.
- Counting sort - python: Implement count sort in python | O(n + k) | Level 2.
- Radix sort: Implement radix sort | O(digits * (n + base)) | Level 4.
- Trie implementation: Implement trie and perform insert, search and delete operations | O(L) | Level 3.
- Trie autocomplete: Implement word autocomplete feature using trie | O(ALPHABET_SIZE * N * L) | Level 3.
- Trie, sorted strings: Print all words in trie, in sorted order | O(ALPHABET_SIZE * N * L) | Level 2.
- Trie, longest prefix matching: Given a string, find a word from trie which matches longest prefix | O(n) | Level 2.
- Pattern matching using suffix tries: Implement suffix tries for pattern matching | O(m) | Level 3.
- DFS traversal: Create a directed graph and performs depth first search(DFS) traversal | O(V + E) | Level 2.
- BFS traversal: Breadth first search(BFS) traversal of directed graph | O(V + E) | Level 2.
- Connected components: Find all connected components in a graph | O(V + E) | Level 2.
- Shortest path in unweighted graph: Find shortest path from src to dst in an unweighted graph | O(V + E) | Level 2.
- Cycle in graph: Check if there is cycle in a directed graph, uses DFS | O(V + E) | Level 3.
- Topological sort: Topological order of directed acyclic graph(DAG) using DFS | O(V + E) | Level 3.
- Shortest path of DAG: Find shortest in a directed acyclic graph from a source vertex to all reachable vertex | O(V + E) | Level 3.
- Dijkstras shortest path: Implement Dijkstras shortest path algo | O(E * log(V)) | Level 3.
- Bellman ford: Bellman ford algo to find shortest path in a graph | O(VE) | Level 3.
- Triagles in graph: Given a graph(directed or undirected), count the number of triagles present | O(N^3) | Level 2.
- Implement disjoint sets (Python): Implement union find data structure with path compression and rank in Python | O(1) | Level 2.
- Implement disjoint sets (Go): Implement union find data structure with path compression and rank in Go | O(1) | Level 2.
- Undirected graph cycle detection: Check if undirected graph has cycle or not using union find | O(V + E) | Level 2.
- Kruskals algo - MST: Kruskals algorithm to find minimum spanning tree(MST) of undirected graph | O(ElogE) | Level 3.
- Job sequencing problem: Given set of jobs with deadline and profit, find seq for max profit | O(N) | Level 4.
- Square root decomposition - Python: Implement square root decomposition method for range sum query in Python | O(sqrt(n)) | Level 2.
- Square root decomposition - Go: Implement square root decomposition method for range sum query in Go | O(sqrt(n)) | Level 2.
- Segment Tree - Python: Implement segment tree (iterative approach) in Python | O(logn) | Level 3.
- Segment Tree - Go: Implement segment tree (iterative approach) in Golang | O(logn) | Level 3.
- Binary indexed (Fenwick) tree: Implement BIT (fenwick tree) | O(n) | Level 3.
- Check strings has unique characters: Check if a string has all unique characters or not | Level 1.
- 2 strings are permutations: Check if 2 strings are permutations of each other or not | Level 2.
- Update input string: Update(in-place) input string to have space replaced with %20 | O(n) | Level 2.
- Is permutation palindrome: Check if any permutation of given string is palindrome or not | Level 2.
- Check 2 strings, one edit away: Check if 2 strings are max one edit away or not | O(n) | Level 2.
- String compression: Compress string, show count for consecutive repeating characters | O(n) | Level 2.
- Rotate square matrix: Rotate square matrix clockwise by 90 degrees | O(n) | Level 3.
- Clear row and column if 0 found: If an element in a matrix is 0, its entire row and column are set to 0 | O(MxN) | Level 3.
- 2 strings are rotations: Check if 2 strings are rotations of each other or not | O(n) | Level 2.
- Remove duplicates from linked list: Remove duplicates from a linked list | O(n) time and space | Level 2.
- kth from last in linked list: Find kth element from last of a singly linked list | O(n) | Level 3.
- Delete node from linked list: Given only reference to an arbitary node of a linked list, delete that node | O(1) | Level 2.
- Partition linked list: Partition a linked lists with respect to a given value | O(n) | Level 2.
- Sum digits of 2 linked list, digits in reverse order: Add 2 numbers stored in linked list in reverse order(12 is 2->1) | O(n) | Level 2.
- Sum digits of 2 linked list, digits in forward order: Add 2 numbers stored in linked list in forward order(12 is 1->2) | O(n) | Level 3.
- Is linked list palindrome: Check if linked list is palindrome or not | O(n) | Level 2.
- Linked list intersection: Find if two linked list intersect each other | O(m + n) | Level 2.
- Starting node of loop in linked list: Detect loop in linked list and find starting node of loop | O(n) | Level 4.
- Skipped code, mostly theoritical/design questions
- Route between 2 nodes: Given a directed graph, check if there is a route b/w 2 nodes | O(V + E) | Level 2.
- Sorted array to BST: Given a sorted array, create binary search tree(BST) with minimal height | O(N) | Level 3.
- List of depths: Binary tree to linked list for each level | O(N) | Level 2.
- Is tree balanced: Check if a binary tree is balanced | O(N) | Level 2.
- Is BST valid: Check if a tree is valid BST or not | O(N) | Level 3.
- BST inorder successor: Find inorder successor of a node in binary search tree | O(h) | Level 2.
- Project build order: Given projects and there dependent projects, find build order. Graph topological sort problem | O(P + D) | Level 2.
- LCA in binary tree: Find lowest common ancestor in binary tree | O(n) | Level 3.
- LCA in BST: Find lowest common ancestor in binary search tree | O(logn) | Level 2.
- BST sequence: Skipped, not clear
- Check subtree: Given 2 trees, check if one tree is exact subtree of another | O(n + km) | Level 2.
- Check subtree - using preorder: Given 2 trees, check if one tree is exact subtree of another | O(n + m) | Level 2.
- Get random node: Skipped, not clear
- Paths with sum: Count number of paths in binary tree having given sum | O(nlogn) | Level 3.
- Insert M into N: Insert bits in M to N at positions between i and j | Level 2.
- Decimal fraction to binary: Convert binary fraction number between 0 and 1 to binary representation | Level 1.
- Flip a bit, get max sequence of 1s: Flip a bit to get maximum sequence of 1s in sequence | O(b) | Level 2.
- Next largest number, same set bits: Given a positive integer, find next largest number having same number of set bits | O(b) | Level 4.
- Previous number, same set bits: Given a positive integer, find previous number having same number of set bits | O(b) | Level 4.
- Debugger: Explain what
((n & (n - 1)) == 0)
does - Bit flips required to convert: Determine the number of bits need to flip to convert integer A to B | Level 2.
- Swap odd and even bits: Program to swap odd and even bits in an integer | Level 2.
- Update screen array, draw line: Update pixels array based on input pixel points to draw a line | Level 3.
- Skipped, puzzles and mathematical questions
- LLD questions
- Count ways to run n steps: Count the number of ways possible to run stairs having n steps (can take 1, 2 or 3 steps) | O(n) | Level 2.
- Path of robot in grid: Find path traversed by robot to reach from 0, 0 to row - 1, col - 1 | O(rc) | Level 3.
- Find magic index: Find magic index from an sorted array having distinct elements | O(log(n)) | Level 2.
- Find magic index, duplicates allowed*: Find magic index from an sorted array (having duplicates) | O(log(n)) | Level 3.
- Generate all subsets of a set: Generate all subsets of a given set | O(n * 2^n) | Level 3.
- Generate all subsets, binary method*: Generate all subsets of a given set, binary representation method | O(n * 2^n) | Level 2.
- Multiply 2 integers: Multiply 2 positive integers without using multiply operator | O(log(s)) | Level 2.
- Tower of hanoi: Print steps to solve tower of hanoi problem for n disks | O(2^n) | Level 3.
- Compute all permutations - Unique chars*: Compute all permutations of a given string having unique characters | O(n^2 * n!) | Level 3.
- Compute all permutations - Repeated chars: Compute all permutations of a given string having repeated characters | O(n^2 * n!) | Level 4.
- Pair of valid parens: Print all valid combinations of n pairs of parentheses | O(2^n) | Level 3.
- Paint fill: Fill surrounding area with new color | O(r * c) | Level 2.
- Ways to represent n cents: Find number of ways to represent n cents using quarters, dimens, nickels and pennies | O(n * NUM_OF_DENOMS) | Level 4.
- Place 8 queens on 8x8: Print all ways to arrange 8 queens on a 8x8 chessboard so that none attack any other | O(GRID_SIZE^3) | Level 4.
- Stack boxes to maximize height: Stack boxes to to have maximum height | O(n) | Level 4.
- Boolean evaluation ways: Total number of ways to get expected boolean result from a boolean expression | O(n) | Level 3.
- System design questions
- Merge 2 sorted arrays, in place: Merge 2 sorted arrays, in place | O(A + B) | Level 2.
- Groups anagrams: Write a method to sort an array of strings so that all the anagrams are next to each other. | O(MxNxlog(N)) | Level 2.
- Search element in rotated sorted array: Search an element from rotated sorted array | Level 3.
- Sorted search, no size: Search an element from an infinite sized(size of array not given) sorted array | O(log(p)) | Level 2.
- Search in sparse array: Search a string from sparsely populated array of strings (other places has empty string) | O(log(n)) | Level 2.
- Sort big file: Skipped code, conceptual
- Missing int: Skipped code, conceptual
- Find all duplicates in array: Find all duplicates in array (range 1 to 32,000) with memory 4k | O(n) | Level 2.
- Search in sorted matrix: Search for an element in a matrix having each row and each column sorted | O(M + N) | Level 2.
- Rank from stream: Find rank of an element from a stream of data | O(logn) | Level 3.
- Rank from stream - python: Find rank of an element from a stream of data | O(logn) | Level 3.
- Peaks and valleys, sorting method: Arrange an unsorted in alternating sequence of peaks and valleys | O(NlogN) | Level 2.
- Peak and valley, O(n) method*: Arrange an unsorted array in alternating sequence of peaks and valleys | O(n) | Level 3.
- Skipped
- Skipped
- Skipped
- General DB concepts and questions
- Questions on thread and concurrency issues
- Swap 2 numbers: Swap 2 numbers, inplace | O(1) | Level 1.
- Word frequency: Find frequency of words in list of words | O(N) | Level 2.
- Intersection: Skipped, mathematical
- Tic tac win: Skipped code, design
- Factorial zeros: Compute number of trailing 0s in n factorial | log(n) | Level 2.
- Smallest difference: Find smallest difference b/w pair of elements from 2 arrays | O(Alog(A) + Blog(B)) | Level 2.
- Number max: Skipped, do in C language
- English int: Skipped code
- Arithmetic operations: Skipped code
- Year with max population: Given birth and death years, find year with max population | O(Y + P) | Level 3.
- Diving board: Find number of lengths possible using 2 lengths k times | O(2^k) | Level 2.
- Diving board - optimized: Find number of lengths possible using 2 lengths k times | O(k) | Level 3.
- XML encoding: Skipped, uses some predefined methods - refer random/practice/xml_encoding.py
- Bisect squares: Skipped, not clear
- Best line: Skipped code
- Master mind: Given solution and guess for 4 slots of RGBY string, find hits and pseudo hits | O(n) | Level 2.
- Sub sort: Find indices of array which needs to be sorted to make whole array sorted | O(N) | Level 3.
- Largest sum of subarray: Given an unsorted array(+ve and -ve numbers), find max sum possible of a subarray | Kadane's algo | O(N) | Level 3.
- Pattern matching: Skipped, not clear
- Pond sizes: Given matrix having water(0) and land, find the size of ponds | O(MN) | Level 2.
- T9 number to string: Skipped code
- Sum swap: Find pair of elements from 2 given array to make sum of 2 arrays same | O(A + B) | Level 3.
- Langton's Ant: Skipped code
- Rand7 from rand5: Implement rand7 using rand5 | Level 3.
- Pairs having given sum: Given an array and required sum, find pairs in array that sums to required sum | O(n) time and space | Level 2.
- Pairs with sum - python: Find all pairs of integers with an array which sum to specified sum | O(N) | Level 2.
- LRU cache impelementation: Put and Get operations implemented in LRU cache | Level 3.
- Evaluate expression: Evaluate arithmetic expression(without parentheses) | O(N) | Level 3.
- Add 2 numbers: Add 2 numbers without arithmatic operations | OlogN) | Level 2.
- Shuffle cards: Given deck of cards, shuffle it | O(N) | Level 2.
- Random set: Generate random set having m elements from an array having n elements | O(N) | Level 2.
- Missing number: Skipped, not clear
- Letters and numbers: Find longest subarry having same number of letters and numbers | O(N) | Level 3.
- Count 2's: Skipped, not clear
- Baby names: Get count of synonym names | O(B + P) | Level 3.
- Circus tower: Given list of pair of words, find longest increasing sequence | O(nlogn) | Level 3.
- Kth multiple - 3, 5 and 7: Find kth number such that the only factors are 3, 5 and 7 | O(k) | Level 3.
- Majority element from array: Find majority(more than n/2 times) element from an array | Moore's voting algo | O(N) | Level 2.
- Majority element from array - python: Find majority(more than n/2 times) element from an array | Moore's voting algo | O(N) | Level 2.
- Word distance: Given list of words, find shortest distance b/w 2 given words | O(A + B) | Level 2.
- Binary tree to doubly linked list: Convert a binary tree to doubly linked list | O(N) | Level 3.
- Re-space: Add spaces in sentence to have min unrecognized chars | O(N^2) | Level 4.
- Smallest K numbers: Given unsorted array find k smallest numbers | O(N) | Level 3.
- Longest word: Given list of words, find longest word that can be found using other words | O(nlogn + L^2) | Level 3.
- The masseuse: Given list of meetings, find max meeting minutes without taking any adjacent meetings | O(N) | Level 2.
- The masseuse - space optimized: Given list of meetings, find max meeting minutes without taking any adjacent meetings | O(N) | Level 3.
- Multi search: Given a string and list of smaller strings, search all smaller strings in bigger string - trie using dict | O(b^2 + kt) | Level 3.
- Multi search - optimal: Given a string and list of smaller strings, search all smaller strings in bigger string | O(kt + bk) | Level 3.
- Shortest supersequence: Find smallest subarray of bigger array having all elements of smaller array | O(SB^2) | Level 2.
- Missing number: Given an array having numbers from 1 to N but one missing, find missing | O(N) | Level 2.
- Missing 2 numbers: Given an array having numbers from 1 to N but 2 numbers missing, find missing numbers | O(N) | Level 2.
- Track median, stream of numbers: Keep track of median from stream of numbers | O(logn) track and O(1) get median | Level 4.
- Volume of histogram: Given set of histogram bars, find max water logged | O(N) | Level 3.
- Word transform: Skipped, not clear
- Max black square: Skipped, not clear
- Max submatrix: Given NxN matrix having +ve and -ve numbers, find submtrix having max sum | O(N^6) | Level 2.
- Word rectangle: Skipped code
- Sparse similarity: Given list of documents, find similarity b/w pairs | O(D^2 * W) | Level 2.
- Karatsuba algo: Efficient way to multiply 2 numbers, karatsuba algo | O(n^1.58) | Level 4.
- Level order tree traversal: Level order traversal of a tree | O(n^2) | Level 2.
- Level order tree traversal - python: Level order traversal of a tree | O(n^2) | Level 2.
- Level order tree traversal using queue*: Level order traversal of a tree using queue | O(n) time and space | Level 2.
- Level order tree traversal using queue - python*: Level order traversal of a tree using queue | O(n) time and space | Level 2.
- Edit distance - O(3^m): Find minimum operations required to convert a source string to target string | O(3^m) | Level 3.
- Edit distance DP approach: Find minimum operations required to convert a source string to target string | O(MxN) | Level 3.
- Edit distance DP approach - python: Find minimum operations required to convert a source string to target string | O(MxN) | Level 3.
- Flip your caps: You all will conform | flip your cap(s) puzzle | Level 3.
- Find 1-D peak: Find 1-D peak from an array | Level 2.
- Find 2-D peak: Find 2-D peak from a 2-D array | Level 3.
- Find second largest number: Find second largest number from an array | Level 1.
- Find element with rank k: Find element with rank k(or kth smallest number) between 2 sorted arrays in ascending sorted | O(k) | Level 1.
- Find element with rank k - python: Find element with rank k(or kth smallest number) between 2 sorted arrays in ascending sorted | O(k) | Level 2.
- Find element with rank k - log(k)*: Find element with rank k(or kth smallest number) between 2 sorted arrays in ascending sorted having distinct elements | O(log(k)) | Level 3.
- Find element with rank k - log(k), python*: Find element with rank k(or kth smallest number) between 2 sorted arrays in ascending sorted having distinct elements | O(log(k)) | Level 3.
- Longest increainng subsequence - O(n^2): Find length of longest increasing subsequence from an unsorted array | O(n^2) | Level 3.
- Longest increainng subsequence - O(nlogn)*: Find length of longest increasing subsequence from an unsorted array | O(nlogn) | Level 3.
- Binary representation: Print binary representation of an integer | Level 1.
- Knapsack problem: Given a knapsack (bag with capacity W), and N items having weights and values, select items such that value is maximized | O(nxW) | Level 4.
- Knapsack problem - python: Given a knapsack (bag with capacity W), and N items having weights and values, select items such that value is maximized | O(nxW) | Level 4.
- Knapsack problem, Maximize weight: Given a knapsack, maximize weights that can be carried in given knapsack, No item values given | O(nxW) | Level 4.
- Knapsack problem, Maximize weight - python: Given a knapsack, maximize weights that can be carried in given knapsack, No item values given | O(nxW) | Level 4.
- Min from sorted rotated: Find min element from sorted rotated array | O(log(n)) | Level 3.
- Tree level with max width: Find tree level having max width/nodes | O(n) | Level 2.
- Tree level with max width - python: Find tree level having max width/nodes | O(n) | Level 2.
- Print fibonacci numbers: Print first n fibonacci numbers | O(n) | Level 1.
- Print prime numbers: Print all prime numbers from 1 to n, sieve of eratosthenes method | O(sqrt(n)log(log(n))) | Level 3.
- Find min range, k sorted arrays: Find min range which will have elements from all k arrays | O(n * k) | Level 3.
- Min positive integer missing: Find minimum positive number missing from an array having random integers | O(n) | Level 2.
- Min positive integer missing - O(1) space*: Find minimum positive number missing from an array having random integers | O(n) | Level 3.
- Create sequence of 'a' and 'b': Given 2 numbers A and B, create sequence with at max 2 consecutive 'a' and 'b' | O(A + B) | Level 3.
- Check strings same: Write a function to check if 2 strings are same, ignoring case | Level 1.
- Multiple of 4: Check if a number of 4 or not | Level 1.
- Find 7n/8: Find 7n/8 without using * and / operators | Level 1.
- Clear both elements: Clear both array elements having at least a 0 and 1 | Level 1.
- Binary palindrom: Check if a numbers binary representation is palindrome or not | Level 2.
- Product of elements: Create a array having product of all elements except element at self index | Level 2.
- Next word in dictionary: Given a string, find next dictionary word | Level 2.
- Find log(n): Write one liner program to find log(n) with some base | O(n/b) | Level 1
- Binary search tree: BST insert, traverse, delete operations | Level 2.
- Binary search tree - python: BST insert, traverse, delete operations | Level 2.
- AVL trees: Implement AVL balanced trees - Insert, delete, search | Level 3.
- AVL trees - python: Implement AVL balanced trees - Insert, delete, search | Level 3.
- Linked list in python: Implement linked list in python.
- Reverse linked list: Reverse a linked list | O(n) | Level 3.
- Happy number: Check if a given number is happy or not | O(n) | Level 2.
- Median in 2 sorted arrays: Find median from 2 sorted arrays | O(log(min(m + n))) | Level 4.
- Longest palindrome: Find longest palindrome from a given string | O(n^2) | Level 3.
- Spiral matrix: Given a number N, create matrix having values from 1 to N^2 in spiral form | O(N^2) | Level 3.
- Print matrix in spiral: Given a matrix, print its elements in clockwise spiral form | O(MxN) | Level 3.
- Print matrix in spiral reverse: Given a matrix, print its elements in anticlockwise spiral form | O(MxN) | Level 3.
- Look and say sequence: Print look and say sequence for given number of input lines | O(N) | Level 2.
- LCM and HCF: Find GCD(or HCF) and LCM of 2 numbers | Level 1.
- Separate positives and negatives: Move all positive to start and negative to end of array, 2 pointer problem, problem adapted from sort array of 0s and 1s | O(n) | Level 2.
- Track kth largest, stream of numbers: Keep track of kth largest number from a stream of numbers | O(k) | Level 2.
- Check prime: Check if a given number is prime or not | O(sqrt(n)) | Level 2.
- Find square root: Find square root of a number using babylonian convergence method | Level 4.
- Substring matching, Rabin karp: Implement rabin karp algo for substring matching | O(m + n) | Level 4.
- Substring matching, Rabin karp - python: Implement rabin karp algo for substring matching | O(m + n) | Level 4.
- Connections in matrix: Count possible connections in matrix of 0s and 1s | O(MxN) | Level 2.
- Next power of 2: Find next power of 2 for a given number | Level 1.
- Round off float: Round off a float number to nearest integer | Level 1.
- Sum of digits: Find sum of digits of a given integer | Level 1.
- Generic linked list: Generic linked list in C language | Level 3.
- Count frequency of numbers: Count frequency of numbers in array | O(N) time and space | Level 1.
- Count frequency, without space: Count frequency of numbers in array | O(N) time and O(1) space | Level 2.
- Repeating numbers: Find all repeating numbers in a array | O(N) | Level 2.
- Inversion of 3: Find number of combinations which follows: a[i] > a[j] > a[k] with i < j < k in a unsorted array | O(N^2) | Level 2.
- Equilibrium index: Find equilibrium index in a array(Equal sum of left and right sub array) | O(N) | Level 2.
- Leaders in array: Print all leaders in array(greater than all elements right to that) | O(N) | Level 1.
- Odd occurring numberr: A array has all numbers occurring even numbers of times and 2 occurring odd number of times, find these 2 numbers | O(N) | Level 2.
- Even occurring numbers: Find 2 numbers in array(numbers from 1 to n - 2) occurring even number of times, other all occur odd number of times | O(N) | Level 3.
- Common in 3 sorted arrays: Find common elements in 3 sorted arrays | O(n1 + n2 + n3) | Level 1.
- Sorted subsequence of size 3: Find sorted subsequence of size 3 in an unsorted array | O(N) time and space | Level 3.
- Sorted subsequence of size 3, O(1) space: Find sorted subsequence of size 3 in an unsorted array | O(N) time | Level 4.
- Max average of len K: Find sub array of len K having maximum average | O(N) | Level 2.
- Subarray having given sum: Find a sub array(positive numbers) having sum | O(N) | Level 3.
- Triplets in GP: Given a sorted array, print triplets in GP | O(N^2) | Level 2.
- ASCII to int: Given an ascii string convert it to integer, atoi conversion | O(N) | Level 2.
- Largest sum of rotated subarray: Find max sum of rotated subarray | O(N) | Level 3.
- Triplet having given sum: Find triplets in a sorted array which sums to a given sum | O(N^2) | Level 2.
- Triplet having smaller sum: Find triplets in a sorted array which sums less than given sum | O(N^2) | Level 2.
- Distinct pairs: Find number of distinct pairs in unsorted array | O(N) | Level 4.
- Is array subset: Given 2 sorted arrays, check if arr2 is subset of arr1 | O(N) | Level 1.
- Count 0s in sorted array: Given a sorted array of 1s and 0s, find number of 0s in that array | O(logn) | Level 2.
- Merge required to make palindrome: Number of merge operations required to make an unsorted array palindrome | O(N) | Level 2.
- Jolly jumper sequence: Check if an unsorted array is jolly jumper sequence | O(N) | Level 2.
- Min number not possible: Find the min num not possible as any subset of sorted array | O(N) | Level 4.
- Subarray with equal 0 and 1: Find max subarray having equal 0s and 1s | O(N^2) | Level 2.
- Max diff btwn elements: Find max diff btwn 2 elements in array such that larger appears later | O(N) | Level 2.
- Maximize index diff: Find max(j - i) such that A[j] > A[i] | O(N) | Level 3.
- Max subarray len, arrange contiguous: Max subarray len whose elements can be arranged in contiguous sequence | O(N^2) | Level 2.
- String anagram having given md5 hash: Given an input string, md5 hashes and long list of words, find anagram of given string which has given hash | Level 3.
- JSON parser: Partial JSON parser, Ecko question | Level 2.
- Max product of subarray, size k: Find max product of a subarray, size k | O(N) | Level 2.
- Max and min product of subset: Find max and min product of subset in array | O(N) | Level 2.
- Max subarray product, 2 traversal: Find max subarray product, 2 traversals used | O(N) | Level 3.
- Max subarray product, single traversal*: Find max subarray product, single traversal | O(N) | Level 3.
- Triplet with max product: Find triplet in array with max product | O(N) | Level 2.
- Max product - index diff and min: Find max value of abs(i - j) * MIN(a[i], a[j]) from unsorted array | O(N) | Level 2.
- Max product of increasing triplet: Find max product of increasing triplet from unsorted array | O(N^2) | Level 3.
- Max min, value index pair: Find max value of (a[i] - i) - (a[j] - j) from an unsorted array | O(N) | Level 2.
- Min unique array sum: Increment array elements until all elements become unique and find sum of all unique elements | O(N) | Level 2.
- Max K such that K elements >= K: Find max k such that array has k elements greater than equal to k | O(N) | Level 2.
- Min subarray len, sum > X: Min subarray len having sum greater than X | O(N) | Level 2.
- Max sum with no elements adjacent: Find max sum with no 2 elements adjacent | O(N) | Level 3.
- Longest bitonic subsequence: Find longest bitonic subsequence in a array | O(N) | Level 3.
- Rotations to maximize sum(i * a[i]): Find number of right rotations required to maximize sum(i * a[i]) | O(N) | Level 2.
- RGB merging, get min count: Array has RGBs, merge different element and get min elements left O(N) | Level 2.
- Count strictly increasing subarrays: Count the number of strictly increasing subarrays possible | O(N) | Level 2.
- Count subarrays with even sum: Given an unsorted array, count the number of subarrays with even sum | O(N) | Level 3.
- Smallest number missing: Given a sorted array - size n, elements 0 to n - 1. Find smallest number missing | O(logn) | Level 2.
- Max sum path, 2 sorted arrays: Given 2 sorted arrays, find max sum path | O(M + N) | Level 3.
- Min distance between 2 elements - O(N^2): Find min distance 2 elements in unsorted array | O(N^2) | Level 2.
- Min distance between 2 elements - O(N): Find min distance 2 elements in unsorted array | O(N) | Level 2.
- Min distance between 2 elements, python - O(N): Find min distance 2 elements in unsorted array | O(N) | Level 2.
- Stock buy sell to maximize profit: Given stock prices, find days to buy and sell so that profit can be maximized | O(N) | Level 3.
- Merge 2 sorted arrays as contiguous sorted: Given 2 sorted arrays, merge them as contiguous sorted arrays | O(M * N) | Level 4.
- Steps to get given array: Find the number of steps required to get given array from all 0s array | O(K * N) | Level 2.
- Index of 0 flipped to get max 1 seq: Find the index of 0 to be changed to 1 to get max 1s sequence | O(N) | Level 3.
- Max sum after k negations: Find max sum of array elements after k negations | O(K * N) | Level 2.
- Max 0s after flipping subarray - O(N^2): Find max 0s in binary array after flipping a subarray | O(N^2) | Level 2.
- Max 0s after flipping subarray - O(N): Find max 0s in binary array after flipping a subarray | O(N) | Level 3.
- Find floor and ceil in array - O(N): Find floor and ceil of X from sorted array | O(N) | Level 1.
- Find floor and ceil in array: Find floor and ceil of X from sorted array | O(logn) | Level 2.
- Find floor and ceil in array - python: Find floor and ceil of X from sorted array | O(logn) | Level 2.
- Convert integer to comma format: Given an integer, convert it to string with comma notation - Indian and US | O(N) | Level 2.
- Reverse sentence: Given a sentence, reverse it's individual words | O(N) | Level 2.
- Reverse sentence - python: Given a sentence, reverse it's individual words | O(N) | Level 2.
- Is symmetric tree: Check if a given tree is symmetric/self mirror image or not | O(N) | Level 2.
- Find mirror image: Find mirror image of a given binary tree | O(N) | Level 2.
- Left and right views of tree: Print left and right views of binary tree | O(N) | Level 2.
- Left/right rotate array: Rotate array left or right by given number of times | O(N) | Level 3.
- Knight's shortest path: Find shortest path from source to destination for a knight on NxN board | BFS | O(N^2) | Level 3.
- Tree inorder iterative: Tree inorder traversal without recursion, iterative approach using stack | O(N) | Level 2.
- Tree preorder iterative: Tree preorder traversal without recursion, iterative approach using stack | O(N) | Level 2.
- Tree postorder iterative: Tree postorder traversal without recursion, iterative approach using stack | O(N) | Level 2.
- Vertical level order tree traversal: Perform vertical level order tree traversal | O(n) | Level 2.
- Top view of binary tree: Print elements seen from top view of a binary tree | O(N) | Level 2.
- Bottom view of binary tree: Print elements seen from bottom view of a binary tree | O(N) | Level 2.
- Tree nodes level by level: Print binary tree nodes level by level in separate lines | O(N) | Level 2.
- Nodes with distance K in binary tree: Print all nodes which are K distance away from given node in binary tree | O(N) | Level 4.
- Tree spiral level order: Print tree nodes in spiral level order | O(N) | Level 3.
- Find diameter(width) of tree: Find diameter(or max width) of a tree | O(N) | Level 2.
- Nodes with K distance from leaf: Nodes with k distance from leaf in tree | O(N) | Level 3.
- Sort array of 0s, 1s and 2s: Sort array having 0s, 1s and 2s | O(N) | Level 2.
- Kth largest number, Heap method: Find Kth largest number from an unsorted array | O(k + (n-k)logk) | Level 2.
- Kth smallest number, QuickSort method: Find Kth smallest number from an unsorted array | O(N) | Level 3.
- Longest common subsequence: Find LCS in given 2 strings | O(M * N) | Level 3.
- Subset having equal sum: Given an array, check if it can be partitioned in 2 subsets having equal sum | O(N * SUM) | Level 3.
- Kth smallest from BST: Find Kth smallest number from a BST | O(K) | Level 3.
- Next greater element: Print NGEs for all elements in given array | O(N) | Level 3.
- Cut rod to have max profit: Find max profit obtainable by cutting up the rod and selling the pieces | O(N^2) | Level 3.
- Max product, rope cutting: Find max product obtained by cutting rope of different sizes | O(N^2) | Level 3.
- Custom split string: Split string with substrings enclosed in quotes as single | O(N) | Level 2.
- Infix to postfix expression converter: Convert infix expression into postfix | O(N * N) | Level 3.
- Job sequencing problem: Given set of jobs with deadline and profit, find seq for max profit | O(N^2) | Level 3.
- Subarray sum less than K: Count subarrays having sum less that k | O(N) | Level 3.
- Smallest num not subset sum: Given sorted array, find min num which is not subset sum of array | O(N) | Level 3