# Practice for cracking any coding interview

Coding questions in this article are **difficulty wise ordered**. The idea of this post is to target two types of people.

**Competitive Programming Preparation (For I**It is recommended to finish all questions from all categories except possibly Linked List, Tree and BST. However at least 10 questions from these categories should also be covered. If you have never done competitive programming before, it is strongly recommended to see How to Begin with Competitive Programming first. If you wish to get yourself prepared with a language first, you may first begin C++ Track or Java Track^{st}and II^{nd}Year Students) :**Interview preparation**It is recommended to cover all topics. In every every topic, you can start from questions according to your comfort level.

The practice system tells you exactly the test case where your code failed. In case you need more clarity about a question, you may use expected output button to see output for your given input. You can also view successful submissions of others in case you are stuck. ** To see solution of others**, please click “All Submissions” button at the bottom of problem statement.

**Topics : **

- Print the pattern (You only need to write function here)
- Print table (This is a full code problem. Please see sample codes here before attempting the problem)
- Series AP
- Series GP
- Closest Number
- Armstrong Numbers
- Sum of digits of a number
- Reverse digits
- Print the Kth Digit
- Binary number to decimal number
- Jumping Numbers
- GCD of two numbers
- LCM of two numbers
- Add two fractions
- GCD of array
- Factorial of a number
- Compute nPr
- Compute nCr
- Largest prime factor
- Perfect Numbers
- Pair cube count
- Find Nth root of M
- Prime Number
- Sieve of Eratosthenes
- Sum of all prime numbers between 1 and N.
- Pairs of prime numbers

**Related Learning Resources : **Mathematical Algorithms and Number Theory

- Count Squares
- 3 Divisors
- Check if four points form a square
- Check for power
- Overlapping rectangles
- Trailing zeroes in factorial
- Angle between hour and minute hand
- Number Of Open Doors
- Triangular Numbers
- Nth Even Fibonacci Number
- Last two digit Fibonacci
- Squares in a Matrix
- Day of the week

**Related Learning Resources :** Puzzles

- Array operations (Search, insert, delete)
- Array alternate printing
- Maximum and minimum in an array
- Second largest in array
- Sum of array elements
- Reverse an Array
- Rotate Array
- Count of smaller elements
- Remove duplicate elements from sorted Array
- Count possible triangles
- Leaders in an array
- Minimum distance between two numbers
- Sorted subsequence of size 3
- Maximum Sub Array
- Majority Element
- Wave Array
- Maximum Index
- Max sum path in two arrays
- Product array puzzle
- Find duplicates in a small ranged array
- Find Missing And Repeating
- Stock buy and sell
- Trapping Rain Water
- Pair with given sum in a sorted array
- Chocolate Distribution Problem
- Longest Consecutive subsequence
- Three way partitioning

**Related Learning Resources :** Array Data Structure

- Check for palindrome
- Check for anagram
- Anagram Palindrome
- Title case conversion
- Sort the string
- Merge two strings
- Save Ironman
- Good or Bad string
- URLify a given string
- Extract Maximum
- Reverse words in a given string
- Implement strstr
- Check for subsequence
- Check for rotation
- Check if two strings are k-anagrams
- Uncommon characters
- Anagram Search
- First repeating character
- First non-repeating character
- Longest Distinct characters in string
- Longest Palindromic Substring
- Find k-th character in string
- Smallest window in a string containing all characters of another string
- Add Binary Strings
- Multiply two Strings
- Nearest multiple of 10

**Related Learning Resources** : String Data Structure

- Linear Search
- Facing the sun
- Magnet Array Problem
- Binary Search
- Floor in a Sorted Array
- Count occurrences in a sorted array
- Search in a sorted and rotated
- Find the missing number
- Missing element of AP
- Square root of a number
- Find Transition Point in a Sorted Binary Array
- Last index of One
- Peak element
- Allocate minimum number of pages
- Common elements in three sorted
- Smallest Positive missing number

**Related Learning Resources** : Searching Algorithms

- Check if array is sorted
- Sort a binary array
- Sort an array of 0s, 1s and 2s
- Bubble Sort
- Insertion Sort
- Selection Sort
- Quick Sort
- Merge Sort
- Sort an array when two halves are sorted
- Relative Sorting
- Triplet Sum in Array
- Minimum Swaps to Sort
- Sorting elements by frequency
- Triplet Family
- Count the triplets

**Related Learning Resources** : Sorting Algorithms

- Count distinct elements
- Array Subset of another array
- Nuts and Bolts Problem
- Count frequencies of elements
- Check if two arrays are equal or not
- First element to occur k times
- In First But Second
- Non-Repeating Element
- Group Anagrams Together
- Winner of an election
- Check for a pair with given sum
- Count distinct pairs with difference k
- Count pairs with given sum
- Find all four sum numbers
- A Simple Fraction
- Largest Fibonacci Subsequence

**Related Learning Resources** : Hashing Data Structure

- Transpose of Matrix
- Print Matrix in snake Pattern
- Print a given matrix in spiral form
- Is Sudoku Valid
- Count zeros in a sorted matrix
- Squares in a Matrix
- A Boolean Matrix Question
- Search in row-wise and column-wise sorted
- Find the row with maximum number of 1s
- Count pairs Sum in matrices
- Median In a Row-Wise sorted Matrix

**Related Learning Resources** : Matrix Data Structure

- Print Pattern
- Handshakes
- Tower of Hanoi
- Josephus problem
- Recursively remove all adjacent duplicates
- Possible words from Phone digits
- Flood fill Algorithm
- Permutations of a string

**Related Learning Resources** : Recursion

- Write your own power function
- Program for n-th Fibonacci Number
- K-th element of two sorted Arrays
- Median of two sorted arrays
- Karatsuba Algorithm
- The Painter’s Partition Problem
- Convex Hull
- Counting inversions

**Related Learning Resources** : Divide and Conquer Algorithms

- Print a Linked List
- Length of a linked list
- Node at a given index in linked list
- Middle of a linked list
- n-th node from end of a linked list
- Delete a node
- Remove every k’th node
- Delete N nodes after M nodes of a linked list
- Delete without head pointer
- Rearrange a linked list
- Segregate even and odd (Using only one traversal)
- Reorder List
- Polynomial Addition
- Insert in a Sorted List
- Swap nodes in pairs
- Reverse a linked list
- Reverse a Linked List in groups of given size.
- Check for palindrome
- Flattening a linked list
- Get intersection point
- Remove duplicates from sorted list
- Remove duplicates from unsorted lists
- Sort a linked list of 0s, 1s and 2s.
- Circular Linked List
- Detect loop in a linked list
- Find length of Loop
- Remove loop in a linked list
- Add two numbers represented by linked lists
- Clone a linked list with random pointers
- Add 1 to a number represented as linked list
- Add two numbers represented as linked list
- Multiply two linked lists
- Merge two sorted linked lists
- Merge Sort on Linked List
- Intersection of Two Linked Lists
- Union of Two Linked Lists

**Related Learning Resources** : Linked List Data Structure

**Doubly and Circular Linked Lists**

- Insert a node in Doubly linked list
- Delete node in Doubly Linked List
- Circular Linked List Traversal
- Split a Circular Linked List into two halves
- Insert in Sorted way in a Sorted DLL
- QuickSort on Doubly Linked List
- Merge Sort on Doubly Linked List
- Rotate doubly Linked List by P nodes
- XOR Linked List

**Related Learning Resources** : Doubly Linked List and Circular Linked List.

- Implement Stack using Array
- Implement Stack using Linked List
- Check for balanced parenthesis
- Reverse a stack
- Implement two stacks in an array
- Design a stack with getMin
- The celebrity problem
- Stock Span Problem
- Next Greater Element
- Next Smaller Element
- Longest valid Parentheses

**Related Learning Resources** : Stack Data Structure

- Implement Queue using Linked List
- Implement Queue using Array
- Implement Stack using Queue
- Implement Queue using Stack
- Reversing a Queue
- Circular tour

**Related Learning Resources** : Queue Data Structure

- Equilibrium Point
- Check if there is a subarray with 0 sun
- Longest Sub-Array with Sum K
- Longest subarray with sum divisible by K
- Largest subarray with equal 1s and 0s
- Longest common span with same number of 1s and 0s among two arrays
- Find mximum sum in any subarray of size k
- Count distinct elements in every window of size k
- Check for subarray with given sum

**Related Learning Resources** : Prefix Sum and Sliding Window

- Check if a number is even or odd.
- Number of bit flips
- Game of XOR
- Find bit at a position
- Swap odd and even bits
- Power of 2
- Odd occurring element
- Missing number in array
- Index Of an Extra Element
- Reverse Bits
- Count set bits
- Power Set

**Related Learning Resources** : Bit Magic

- Inorder Traversal
- Preorder Traversal
- Postorder Traversal
- Level order traversal
- Find height of Binary Tree
- Count Leaves in Binary Tree
- Check for Children Sum Property
- Mirror Tree
- Check for Balanced Tree
- Lowest Common Ancestor in a Binary Tree
- Diameter of Binary Tree
- Left View of Binary Tree
- Right View of Binary Tree
- Maximum path sum
- Level order traversal line by line
- Tree from Postorder and Inorder
- Tree from Preorder and Inorder
- Connect Nodes at Same Level
- Zig-Zag level order traversal
- Serialize and Deserialize a Binary Tree
- Leaves to DLL
- Binary Tree to Doubly Linked List
- Binary Tree to Circular Doubly Linked List

**Related Learning Resources** : Tree Data Structure

- BST Search
- BST Insert
- BST Delete
- Minimum in BST
- Inorder Traversal and BST
- Count BST nodes that lie in a given range
- Add all greater values
- Predecessor and Successor in BST
- Closest Neighbor in BST
- Lowest Common Ancestor in a BST
- Convert Level Order Traversal to BST
- Normal BST to Balanced BST
- Pair with given sum in BST
- Check for BST
- Correct BST with two nodes swapped
- Median of BST
- k-th smallest element in BST
- Unique BST’s
- Array to BST
- Preorder Traversal and BST
- Preorder to Postorder
- Leaf nodes from preorder traversal
- Triplet with 0 sum in BST
- Merge two BST ‘s
- Largest BST Subtree

**Related Learning Resources** : Binary Search Tree

- Binary Heap Operations
- Height of Heap
- Heap Sort
- Sort a Nearly Sorted Array
- K Largest Elements
- K-th largest element in a stream
- Median of stream
- Merge k sorted arrays

**Related Learning Resources** : Heap Data Structure

- Print adjacency list
- Breadth First Search
- Depth First Search
- Find whether path exist
- Knight Walk
- Snake and Ladder Problem
- Bipartite Graph
- Detect Cycle in an undirected graph
- Detect Cycle in a directed graph
- Find first n numbers with given set of digits
- Rotten oranges
- Topological sort
- Shortest Source to Destination Path
- Transitive closure of a Graph
- Strongly Connected Components

**Related Learning Resources** : Graph Data Structure

- Fractional Knapsack
- Largest number with given sum
- Activity Selection
- N meetings in one room
- Minimum Platforms
- Minimum number of Coins
- Job Sequencing Problem
- Minimize the heights
- Huffman Coding
- Huffman Decoding
- Minimum Spanning Tree
- Dijkstra for Adjacency Matrix

**Related Learning Resources** : Greedy Algorithms

- Print first n Fibonacci Numbers.
- Count ways to reach the n’th stair
- Cutted Segments
- Kadane’s Algorithm
- Stickler Thief
- Minimum number of jumps
- Total Decoding Messages
- Min Cost Path
- Coin Change
- Longest Common Subsequence
- Consecutive 1’s not allowed
- Edit Distance
- Rod Cutting
- Water Overflow
- Maximum Tip Calculator
- Longest Increasing Subsequence
- Maximum sum increasing subsequence
- Max length chain
- 0 – 1 Knapsack Problem
- Maximum Tip Calculator
- Interleaved string
- Longest Palindromic Subsequence
- Wildcard Pattern Matching
- Box Stacking
- Longest Bitonic subsequence
- Minimum sum partition
- Largest square formed in a matrix
- Word Break
- Matrix Chain Multiplication
- Special Keyboard
- Egg Dropping Puzzle
- Optimal Strategy for a Game

**Related Learning Resources** : Dynamic Programming

- Rat Maze With Multiple Jumps
- Coins and Game
- Hamiltonian Path
- Solve the Sudoku
- Combination Sum – Part 2
- Combination Sum
- Subsets
- Largest number in K swaps
- M-Coloring Problem
- Black and White

**Related Learning Resources** : Backtracking

- Trie Search and Insert
- Trie Delete
- Unique rows in a binary matrix
- Count of distinct substrings
- Word Boggle

**Related Learning Resources** : Trie Data Structure

**Misc Questions to test your overall learning**

- Longest common prefix
- Implement Atoi
- Two numbers with sum closest to zero
- Smallest greater elements in whole array
- Max rectangle
- Find triplets with zero sum
- Counting elements in two arrays
- Merge K sorted linked lists
- Maximum Difference
- Circle of strings
- All possible Word Breaks
- Alien Dictionary
- Design a tiny URL or URL shortener
- Implement LRU Cache

- Sudo Placement : For companies like Amazon, Microsoft, Adobe, .., etc
- Sudo Placement 2 : For companies like TCS, Infosys, Wipro, Cognizant, .. etc
- Aptitude questions asked in round 1 : Placements Course designed for this purpose.
- MCQs asked from different computer science subjects : Subject-Wise Quizzes
- Interview theory and coding questions of all companies : Company wise all practice questions.
- Interview experiences of all companies : Interview corner.
- Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, …
- Must Do Coding Questions Company-wise

## Recommended Posts:

- What coding habits improve timing in coding contest?
- Cracking Technical Interviews
- Cracking Technical Interviews; Freshers
- How to answer a coding question in an Interview?
- BFS using STL for competitive coding
- Recursive Practice Problems with Solutions
- Why is python best suited for Competitive Coding?
- Python Tricks for Competitive Coding
- Must Do Coding Questions Company-wise
- How to attempt Function Coding Questions?
- Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
- Barclays Investment Bank Pune Interview Experience (On-Campus Interview)
- Going to an Interview
- How to be prepared for an interview?
- SQL Interview Questions

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.