100+ Essential Coding Interview Questions to Ace Your Next Tech Interview [Updated]
Feeling Stressed About Coding Interviews? Youβre Not Alone!
Letβs be realβcoding interview questions can be nerve-wracking. The pressure, the whiteboard coding, the algorithm-heavy challengesβ¦itβs enough to make anyone break a sweat. Iβve been there. You spend weeks grinding LeetCode, watching YouTube tutorials, and still feel unprepared when the big day arrives. Sound familiar?
Table Of Content
- Feeling Stressed About Coding Interviews? Youβre Not Alone!
- 100+ Essential Coding Interview Questions
- Array-Based Coding Interview Questions for Freshers
- String-Based Coding Interview Questions for Freshers
- Linked List Coding Interview Questions for Freshers
- Tree-Based Coding Interview Questions for Freshers
- Recursion-Based Coding Interview Questions for Freshers
- Sorting and Searching Coding Interview Questions for Freshers
- Graph-Based Coding Interview Questions for Freshers
- Stack and Queue Coding Interview Questions for Freshers
- Dynamic Programming Coding Interview Questions for Freshers
- Object-Oriented Programming Coding Interview Questions for Freshers
- Bit Manipulation Coding Interview Questions
- Greedy Algorithm Coding Interview Questions
- Math and Logic Puzzle Coding Interview Questions
- Common Coding Interview Questions
Thatβs exactly why I created this ultimate list of 100+ essential coding interview questionsβso you donβt waste time on random problems that might not even matter. These common coding interview questions cover everything: arrays, linked lists, trees, dynamic programming, and even system designβeverything tech companies love to ask.
Whether youβre a seasoned candidate or just starting out, these coding interview questions for freshers will help you build a strong foundation and develop confidence.
Letβs dive in and take the stress out of your prep.
100+ Essential Coding Interview Questions

Array-Based Coding Interview Questions for Freshers
- How do you find the missing number in an array from 1 to n? Use the formula sum = n*(n+1)/2. Subtract actual array sum from it to get the missing number. Time complexity is O(n).
- How do you find the duplicate number in an array? Use Floydβs Tortoise and Hare (Cycle Detection) algorithm for efficient results. Time complexity is O(n), space O(1).
- How do you rotate an array by k positions? Reverse the whole array, reverse first k and then reverse the rest. Time complexity is O(n), space O(1).
- How do you find the maximum subarray sum? Use Kadaneβs Algorithm. Maintain a current max and update global max accordingly.
- How do you merge two sorted arrays? Use two pointers to merge them into a third array. Time complexity is O(n + m).
- Find the intersection of two arrays. Use a HashSet to store one array, then check the second. Time complexity is O(n).
- How do you sort an array of 0s, 1s, and 2s? Use the Dutch National Flag algorithm. It runs in O(n) time.
- Find the leader elements in an array. Traverse from the right, track max so far. Elements greater than all to their right are leaders.
- How do you find the majority element in an array? Use Moore’s Voting Algorithm. Time complexity O(n), space O(1).
- How do you rearrange array elements in alternating positive and negative items? Partition the array, then swap alternately. Time complexity is O(n).
String-Based Coding Interview Questions for Freshers
- Check if a string is a palindrome. Use two pointers from start and end. Compare characters until middle.
- Find the first non-repeating character in a string. Use a frequency counter, then iterate again to find the first. Time complexity is O(n).
- Reverse a string without affecting special characters. Use two-pointer technique while skipping non-alphabetic. Swap only letters.
- Check if two strings are anagrams. Sort and compare or use frequency arrays. Time complexity is O(n log n) or O(n).
- Implement strstr (substring search). Use the KMP algorithm for efficient matching. Time complexity is O(n + m).
- Find the longest common prefix. Sort and compare first and last strings. Check character by character.
- Find the longest palindrome substring. Use dynamic programming or center expansion. Time complexity is O(n^2).
- How do you compress a string (aabcc becomes a2b1c2)? Iterate and count consecutive characters. Concatenate character and count.
- Check if string has all unique characters. Use a set or boolean array. Time complexity is O(n).
- Remove duplicate characters in a string. Use a set to track seen characters. Build a new string skipping duplicates.
Linked List Coding Interview Questions for Freshers
- Detect a loop in a linked list. Use Floydβs cycle detection algorithm. Tortoise and hare pointer method.
- Find the middle element of a linked list. Use slow and fast pointer. Slow will be at middle when fast reaches end.
- Reverse a linked list. Iteratively change next pointers. Use three pointers: prev, curr, next.
- Check if a linked list is a palindrome. Find middle, reverse second half, compare halves. Time complexity is O(n).
- Merge two sorted linked lists. Use a dummy node and iterate. Compare node values and attach accordingly.
Tree-Based Coding Interview Questions for Freshers
- What is the height of a binary tree? Recursively find the height of left and right subtrees. Return max height + 1.
- Check if two trees are identical. Recursively check if both roots, left, and right match. Base case is when both nodes are null.
- Print in-order traversal of a binary tree. Use recursion: Left -> Root -> Right. You can also use a stack for iterative approach.
- Check if a binary tree is a BST. Use recursion with valid range limits. Ensure left < root < right.
- Find lowest common ancestor in BST. Use recursion based on value comparison. If root lies between two nodes, it’s LCA.
Recursion-Based Coding Interview Questions for Freshers
- Find factorial using recursion. Base case is 1. Return n * factorial(n-1). Time complexity is O(n).
- Generate Fibonacci series using recursion. Return fib(n-1) + fib(n-2) with base cases. Inefficient; better with memoization.
- Reverse a string using recursion. Base case is empty string. Return reverse(substring) + first character.
- Check if a number is a power of 2. Recursively divide by 2 and check if equals 1. Base case is 1.
- Find GCD using recursion. Use Euclidean algorithm: gcd(a, b) = gcd(b, a % b). Base case is when b == 0.
Sorting and Searching Coding Interview Questions for Freshers
- Implement binary search. Compare mid element with target. Use divide-and-conquer on sorted array.
- Implement bubble sort. Swap adjacent elements if out of order. Time complexity is O(n^2).
- Implement insertion sort. Insert elements in sorted position one by one. Best case O(n), worst case O(n^2).
- Implement quick sort. Choose pivot, partition array, and sort recursively. Average case is O(n log n).
- Implement merge sort. Divide array into halves, sort and merge them. Time complexity is O(n log n).
Graph-Based Coding Interview Questions for Freshers
- Implement depth-first search (DFS). Use stack or recursion to visit nodes. Mark nodes as visited to avoid cycles.
- Implement breadth-first search (BFS). Use queue to explore neighbors layer by layer. Track visited nodes to prevent repetition.
- Detect a cycle in an undirected graph. Use DFS and track parent of each node. Cycle exists if a visited node is not parent.
- Detect a cycle in a directed graph. Use DFS with recursion stack. Back edge indicates a cycle.
- Topological sort of a DAG. Use DFS or Kahnβs Algorithm. Order tasks with no cyclic dependencies.
Stack and Queue Coding Interview Questions for Freshers
- Implement a stack using two queues. Push to one queue, pop by transferring to other. Maintain latest element at front.
- Implement a queue using two stacks. Push to one stack, pop by reversing to other. Use amortized O(1) operations.
- Check for balanced parentheses. Use stack to track opening brackets. Match with closing ones.
- Evaluate a postfix expression. Use stack to store operands. Apply operators as encountered.
- Implement LRU cache. Use HashMap and Doubly Linked List. Maintain order of usage.
Dynamic Programming Coding Interview Questions for Freshers
- Find nth Fibonacci number using DP. Use memoization or bottom-up approach. Time complexity is O(n).
- 0/1 Knapsack Problem. Use DP table to choose max value within capacity. Time complexity is O(nW).
- Longest common subsequence. Fill DP table based on character match. Result is in last cell.
- Longest increasing subsequence. Use DP to track increasing order. Update max for each element.
- Minimum edit distance between two strings. Use DP to calculate insert, delete, replace. Choose min of all operations.
Object-Oriented Programming Coding Interview Questions for Freshers
- What is encapsulation in OOP? Binding data and methods together. Achieved using classes and access modifiers.
- What is inheritance in OOP? One class acquires properties of another. Supports code reusability.
- What is polymorphism in OOP? Same function behaves differently in contexts. Overloading and overriding are types.
- What is abstraction in OOP? Hides internal details, shows essential features. Done using abstract classes or interfaces.
- Difference between interface and abstract class? Interfaces have only abstract methods (till Java 7). Abstract class can have concrete methods too.
Bit Manipulation Coding Interview Questions
- Check if a number is a power of two.
Use n & (n – 1) to check. If result is 0 and n > 0, it’s a power of two. - Count set bits in an integer.
Use Brian Kernighanβs algorithm. Subtract 1 and AND it with the original number until 0. - Find the only non-repeating element.
Use XOR across all numbers. Duplicate elements cancel out. - Add two numbers without using ‘+’ operator.
Use bitwise XOR for addition and AND + shift for carry. Repeat until carry is zero. - Swap two numbers using bitwise operators.
Use XOR: a = a ^ b, b = a ^ b, a = a ^ b. - Find position of rightmost set bit.
Use n & -n. This isolates the rightmost set bit in binary.
Greedy Algorithm Coding Interview Questions
- Activity selection problem.
Sort by end time and choose non-overlapping intervals. Maximizes task completion. - Minimum number of platforms required for trains.
Sort arrival and departure separately, and simulate overlapping. - Fractional Knapsack Problem.
Sort by value/weight ratio. Take max possible items greedily. - Job Sequencing Problem.
Sort by profit and fill time slots greedily to maximize gain. - Huffman Coding.
Use priority queue to build optimal prefix tree for encoding. - Minimum number of coins.
Use highest denomination coins first (greedy) to reach the total amount.
Math and Logic Puzzle Coding Interview Questions
- Check if a number is prime.
Check divisibility from 2 to βn. Return false if divisible. - Find GCD of two numbers.
Use Euclidean algorithm: gcd(a, b) = gcd(b, a % b). - Check if a number is palindrome.
Reverse the number and compare with original. - Find square root without library.
Use binary search between 1 and n. - Check if number is an Armstrong number.
Sum of each digit raised to power of total digits equals number. - FizzBuzz problem.
Print “Fizz” for multiples of 3, “Buzz” for 5, and “FizzBuzz” for both.
Common Coding Interview Questions
- Reverse an integer.
Extract digits and construct reversed number. Handle overflows. - Convert integer to Roman numeral.
Map integer values to Roman symbols. Greedily subtract values. - Convert Roman numeral to integer.
Add or subtract values based on symbol position. - Excel sheet column number to title.
Convert to base-26 and map to alphabet. - Find majority element.
Use Boyer-Moore voting algorithm for O(n) time. - Find longest common prefix among strings.
Use horizontal scanning or sort then compare first & last. - Implement atoi function.
Trim spaces, handle signs, and parse numbers character by character. - Implement strstr function.
Use two pointers or KMP algorithm for substring search. - Implement pow(x, n).
Use recursion or iterative fast exponentiation with log(n) complexity. - Find missing number in 0 to n.
Sum from 0 to n minus sum of array gives missing number. - Find duplicate number in array.
Use Floydβs cycle detection algorithm or visited index marking. - Detect cycle in an array.
Floyd’s cycle detection technique using slow and fast pointers. - Find kth largest element.
Use heap or quickselect for average O(n) time. - Longest consecutive sequence.
Use HashSet and check sequence starts with n-1 not existing. - Count primes less than n.
Use Sieve of Eratosthenes for efficient counting. - Valid Parentheses.
Use stack to push on opening and pop on matching closing. - Group Anagrams.
Sort each string or use character frequency map as key in HashMap. - Top K Frequent Elements.
Use HashMap for count and Min Heap or Bucket Sort to find top k. - Isomorphic Strings.
Map characters from s to t and ensure consistent mapping. - Minimum Window Substring.
Use sliding window with frequency count comparison. - Decode Ways.
Use DP: ways[i] = ways[i-1] + ways[i-2] depending on digits. - Find First and Last Position of Element in Sorted Array.
Use binary search twice for left and right bounds. - Search in Rotated Sorted Array.
Use modified binary search with pivot consideration. - Median of Two Sorted Arrays.
Use binary search partitioning technique. Complex but optimal. - Wildcard Matching.
Use DP or greedy two-pointer technique with backtracking. - Regular Expression Matching.
Use recursion or DP to match ‘.’ and ‘*’ patterns. - Implement LRU Cache.
Use HashMap with Doubly Linked List for O(1) operations. - Serialize and Deserialize Binary Tree.
Use BFS or DFS with delimiters for nulls. - Sliding Window Maximum.
Use deque to maintain decreasing order of values within window. - Trapping Rain Water.
Use two-pointer technique or precompute left/right max arrays. - Word Ladder.
Use BFS to transform word by changing one letter at a time. - Alien Dictionary (Topological Sort).
Build graph from character orders and apply Kahnβs algorithm.
![100+ Essential Coding Interview Questions to Ace Your Next Tech Interview [Updated] javascript else if](https://www.kaashivinfotech.com/blog/wp-content/uploads/2025/03/FREE-js1-150x150.png)
![100+ Essential Coding Interview Questions to Ace Your Next Tech Interview [Updated] Check if File Exists in Python](https://www.kaashivinfotech.com/blog/wp-content/uploads/2025/03/God-of-War-Remastered-A-Nostalgic-Comeback-for-Fans-28-150x150.png)