This repository collects coding questions (and answers) to prepare coding interviews. The questions categorised based on main topics like Data Structures, Recursion, Algorithms and Common Coding Interview Patterns. Each category includes subcategories covering main topics in this topic. Each question has difficulty level, company tags and a source link (whenever available)
I've created the project to prepare coding interviews. I'm not an expert in this field (yet), so any contributions and improvements are welcome!
- Questions - includes the problem statement, relevant tags: difficulty, company and source link (when available) to the most popular coding platforms. You can try to solve it yourself first or/and move to the solution description section
- Methods - this section provides one or multiple description of methods to solve the problems. It usually starts with the naive solution and goes into optimized ones. This basically helps to solve the problem before jumping into the solution and improves a thinking process (the most important part of coding interviews). Each solution description contains links to solutions in the end.
- Solutions - this section contains the solutions to the problems in Java and Python. These two are probably the most demanded and the most loved languages in the industry, so I try to provide solutions in both of them.
- Sherzod Obidov - a senior software engineer at Google from Uzbekistan, and this project is also inspired from his similar project AlgoDS. Some questions are taken from this project
- Educative.io - probably creators of the best courses for technical interviews preparation. Most questions are taken from their Ace Java Coding Interview Skill Path
- Questions collected - 161
- Full description provided - 10
- Methods provided - 1
- Java solutions - 1
- Python solutions - 0
- Remove even integers from an array (easy)
- Find minimum/maximum value in the array (easy)
- Reverse array (easy)
- Contains duplicate (easy)
- Merge two sorted arrays (easy)
- Find two numbers that add up to "n" (easy)
- First non-repeating integer in array (easy)
- Find k-th minimum/maximum in array (medium)
- Find peak element (medium)
- Maximum sum subarray (medium)
- Array of products except itself (medium)
- Right rotate the array by "n" index (medium)
- Re-arrange positive and negative values (medium)
- Re-arrange sorted array in max/min form (medium)
- Shuffle an Array (medium)
- Find all duplicates in array (medium)
- Find Minimum in Rotated Sorted Array (medium)
- Search in Rotated Array (medium)
- Longest Increasing Subsequence (medium)
- Rotate image / matrix (medium)
- Singly Linked List Implementation: addition, insertion, search, deletion (easy)
- Length of Linked List: iterative and recursive (easy)
- Doubly Linked List Implementation: addition, insertion, search, deletion (easy)
- Find the Middle Node of a Linked List (easy, medium)
- Remove duplicates from a Linked List (easy)
- Union & Intersection of Two Linked Lists (medium)
- Return / Remove the Nth node from end of SLL (medium)
- Merge two sorted SLLs (medium)
- Find Linked List Cycle (medium)
- Check if DLL is palindrome (medium)
- Merge k Sorted Lists (hard)
- Stack Implementation: push, pop, top, isEmpty (easy)
- Queue Implementation: enqueue, dequeue, top, isEmpty, isFull (easy)
- Generate Binary Numbers from 1 to n using a Queue
- Implement Two Stacks using one Array
- Reversing the First k Elements of a Queue
- Implement Queue using Stack
- Implement Stack using Queue
- Sort the values in a Stack
- Evaluate postfix expressions using a Stack
- Next greater element using a Stack
- Check for balanced parentheses using a Stack
- Solve a celebrity problem using a Stack
- Create a Stack where min() gives minimum in O(1) time
- Sum of integers from 1 to n (easy)
- Factorial of a number (easy)
- Computing nth fibonacci number (easy, medium)
- Power of a number (easy)
- Check for Prime number (easy)
- Greatest Common Divisor (easy)
- Least Common Multiple (easy)
- Decimal number to binary (easy)
- Search value in a SLL (easy)
- Reverse a string (medium)
- Check if a string is palindrome (medium)
- Print all permutations of a string (medium)
- Tower of Hanoi (medium)
- Binary Search Tree Implementation: insertion, search, deletion (easy)
- Pre-order, In-order, Post-order traversal of Binary Tree (easy)
- Find the height of a BT (easy)
- Copy of BT (easy)
- Find ancestors of a given node (easy)
- Invert Binary Tree
- Binary Tree left / right side view
- Sum of left leaves
- Flatten BT to a Linked List
- Symmetric tree
- Same tree
- Balanced BT
- Maximum and minimum depth of a BT
- Sorted List to Balanced BST
- Validate BST
- Find the kth minimum/maximum value in a BST (easy)
- Lowest common ancestor of BST
- Mode in BST
- Most frequent subtree sum
- Find the largest element in each row in BT
- Breadth First Search: BFS (easy)
- Depth First Search: DFS (easy)
- Cycle detection in a directed graph (easy)
- Find "Mother Vertex" in a Directed Graph (easy)
- Count the number of edges in an Undirected Graph (easy)
- Check if a path exists between two vertices (easy)
- Check if directed graph is Tree or not
- Find the shortest path: Dijkstra
- Find the shortest path: Bellman-Ford
- Remove edge from a Directed Graph
- Prim's Minimum Spanning Tree (MST) (review)
- KrusKal's Minimum Spanning Tree (MST) (review)
- Topological Sorting (review)
- Is Graph connected (review)
- Undirected Graph bridge detection (review)
- A* heuristic path finding (review)
- Trie implementation: insertion, search, deletion
- Total number of words in a Trie
- Find all the words in a Trie
- Sort the elements of an Array using a Trie
- Word formation from a Given Dictionary using a Trie
- Max Heap implementation (easy)
- Min Heap implementation (easy)
- Convert a Max-Heap to a Min-Heap
- Find k the smallest elements in an Array
- Find k the largest elements in an Array
- Hash Table implementation: add, remove, search
- Find whether an Array is a subset of another Array
- Check if the given Arrays are disjoint
- Find symmetric pairs in an Array
- Trace the complete path of a journey
- Find two pairs in an Array such that a + b = c + d
- Find If a Subarray with a Sum Equal to 0 Exists
- First Non-Repeating Integer in an Array
- Remove Duplicate from a Linked List using Hashing
- Union and Intersection of Lists using Hashing
- Find Two Numbers that Add up to "n"
- Bubble Sort (easy)
- Selection Sort (easy)
- Insertion Sort (easy)
- Counting Sort
- Quick Sort (medium)
- Merge Sort (medium)
- Linear Search (easy)
- Binary Search (easy)
- Find two numbers that add up to "n" (easy)
- Search in a rotated array (easy)
- Find the Median of Two Sorted Arrays
- Find duplicates in an Array
- Search in Sorted Matrix (medium)
- Count element occurrence
- Search insertion position
- Sparse search
- Dutch national flag problem
- Make a change machine!
- Connecting "n" pipes with minimum cost
- Find the Egyptian fraction
- Minimum number of platforms required for a train station
- Find the largest number
- Euclidean algorithm
- Peak element
- Missing number in a sorted Array
- Find the closest number
- Shuffle integers
- Collect coins in minimum steps
- Merge a number of sorted arrays
- Find the floor and ceiling of a number
- Inversion count in an Array
- Fibonacci series using Recursion
- The 0/1 Knapsack Problem
- Longest common substring
- Shortest common super-sequence
- Longest palindromic subsequence
- The coin change problem
- Egg dropping problem
- Strings interleaving
- Edit distance problem
- Calculate the number of nodes in a given graph level
- Print the transpose of a Graph
- Count the paths between two nodes
- Check if a Graph is strongly connected
- Print all the connected components in a Graph
- Removing a giving edge
- Check if a Graph is bipartite