Top 100 DSA Interview Questions (Practice in Java)
Compiled for quick placement preparation
Arrays
1 Find the largest and smallest element in an array
2 Reverse an array
3 Find the second largest element
4 Check if array is sorted
5 Remove duplicates from sorted array
6 Rotate array by k positions
7 Find the missing number in an array
8 Two Sum problem
9 Maximum subarray sum (Kadane’s Algorithm)
10 Merge two sorted arrays
Strings
1 Reverse a string
2 Check if a string is palindrome
3 Count vowels and consonants
4 Check if two strings are anagrams
5 Find the first non■repeating character
6 Remove duplicates from string
7 Find all substrings of a string
8 Check if string contains only digits
9 Longest common prefix
10 String compression
Linked List
1 Create a singly linked list
2 Insert node at beginning
3 Insert node at end
4 Delete a node
5 Reverse a linked list
6 Find the middle element
7 Detect loop in linked list
8 Remove duplicates from linked list
9 Merge two sorted linked lists
10 Find nth node from end
Stack
1 Implement stack using array
2 Implement stack using linked list
3 Check balanced parentheses
4 Reverse a stack
5 Sort a stack
6 Next greater element
7 Evaluate postfix expression
8 Implement min stack
Queue
1 Implement queue using array
2 Implement queue using linked list
3 Implement circular queue
4 Queue using two stacks
5 Generate binary numbers using queue
6 Sliding window maximum
Trees
1 Implement binary tree
2 Inorder traversal
3 Preorder traversal
4 Postorder traversal
5 Level order traversal
6 Height of binary tree
7 Count nodes in binary tree
8 Check if two trees are identical
9 Lowest common ancestor
10 Check if tree is balanced
Searching
1 Linear search
2 Binary search
3 Find first occurrence in sorted array
4 Find last occurrence in sorted array
5 Search in rotated sorted array
Sorting
1 Bubble sort
2 Selection sort
3 Insertion sort
4 Merge sort
5 Quick sort
6 Count sort
7 Find kth largest element
Recursion
1 Factorial using recursion
2 Fibonacci using recursion
3 Sum of digits using recursion
4 Reverse string using recursion
5 Tower of Hanoi
Hashing
1 Count frequency of elements
2 Find duplicates using HashSet
3 Two sum using HashMap
4 Check if array contains duplicates
5 Group anagrams using hashing