About DSA

Practice data structures and algorithms problems commonly asked in technical coding interviews. Covering arrays, linked lists, trees, graphs, dynamic programming, and more, these problems develop your ability to choose the right data structure, analyze time and space complexity, and implement efficient solutions under interview pressure.

Practice 178 interactive coding problems with step-by-step execution visualization.

DSA

Data structures & algorithms

Problems178 problems

Find corresponding node in cloned tree

Find max depth of DOM tree

Collect unique tags in DOM tree

Traverse a binary tree in left-root-right order

Traverse a binary tree in root-left-right order

Traverse a binary tree in left-right-root order

Find longest root-to-leaf path length

Check if a binary tree is mirror-symmetric

Traverse level by level with BFS

Get the nodes visible from the right side

Check if two trees are identical

Flip every node by swapping child pointers

Check if root-to-leaf path sums to target

Count paths with target sum (not necessarily root-to-leaf)

Longest path between any two nodes

Verify BST ordering constraints across all nodes

Find LCA using BST ordering

Use inorder order to get sorted BST values

Build a balanced BST from sorted values

Find the element that appears only once when all others appear twice using XOR

Count the number of set bits (1s) in a binary number (Hamming Weight)

Return array where ans[i] is the number of 1s in binary of i

Reverse bits of a 32-bit unsigned integer

Find the missing number in array [0, n] using XOR

Check if a number is a power of two

Add two integers without using + or - operators

Find element appearing once when others appear 3 times

Find two elements appearing once when others appear twice

Find bitwise AND of all numbers in range [left, right]

Flip all bits in binary representation

Check if a number is a power of four

Check if binary has alternating bits (101010...)

Count differing bit positions between two numbers

Find maximum XOR of any two numbers in array

Generate Gray code sequence where adjacent values differ by one bit

Generate all subsets using a bitmask from 0..(2^n - 1)

Sort by popcount (number of 1 bits), then by value

Find how many bits differ between start and goal

Minimum flips to make (a | b) equal to c

Find two numbers in a sorted array that add up to target

Check if string is palindrome (ignoring non-alphanumeric)

Reverse array of characters in-place using two pointers

Reverse only vowels in a string while keeping other characters in place

Reverse word order and remove extra spaces

Remove duplicates from sorted array in-place, return new length

Move all zeroes to end while maintaining order of non-zero elements

Return squares of sorted array in sorted order (handles negatives)

Find two lines that form container holding most water

Find all unique triplets that sum to zero

Sort array of 0s, 1s, 2s in-place using three pointers

Remove all instances of value in-place, return new length

Check if s is a subsequence of t

Merge two sorted arrays into first array in-place

Partition string so each letter appears in at most one part

Calculate how much rain water can be trapped between bars

Find three integers whose sum is closest to target

Check if string can be a palindrome by removing at most one character

Minimum boats to carry people with weight limit

Rotate array to the right by k steps using triple reverse

Find all unique quadruplets that sum to target

Check if typed string could be result of long pressing name

Find intersection of two arrays including duplicates

Remove duplicates allowing at most two of each element

Compare two strings with backspace characters (#)

Compress string in-place using read/write pointers

Find the maximum sum of any contiguous subarray of size k

Find the contiguous subarray of size k with the maximum average

Find the length of the longest substring without repeating characters

Find the minimal length subarray with sum greater than or equal to target

Find the longest subarray of 1s after flipping at most k zeros

Find the longest substring where you can replace at most k characters to make all same

Check if one string contains a permutation of another

Return all start indices where p's anagram appears in s

Find the smallest substring that contains all characters of another string

Find the maximum in each sliding window of size k

Find two numbers that add up to target using hash map

Check if array contains any duplicate values using Set

Check if two strings are anagrams using character frequency

Return the index of the first non-repeating character

Check if ransomNote can be built from magazine letters

Group strings that are anagrams of each other

Find the k most frequent elements using bucket sort

Calculate product of all elements except self without division

Find length of longest consecutive sequence in O(n)

Find maximum profit from one buy and one sell

Find contiguous subarray with largest sum using Kadane algorithm

Find element appearing more than n/2 times using Boyer-Moore

Check whether every opening bracket is closed in the correct order

Design a stack that supports getMin in constant time

Evaluate an expression in Reverse Polish Notation

For each day, find how many days until a warmer temperature

Find next greater element for each value in nums1 based on nums2

Find next greater element in a circular array

Find the largest rectangle area in a histogram

Count how many car fleets arrive at the target

Simplify an absolute Unix-style file path

Remove k digits from a number string to produce the smallest possible number

Decode nested repetition patterns like 3[a2[c]]

Evaluate expression with +, -, *, / and non-negative integers

Count connected components of land cells in a 2D grid

Fill connected pixels in an image with a replacement color

Find the largest connected land area in a binary grid

Deep clone an undirected graph given a start node

Determine whether a path exists between two vertices

Check whether all rooms are reachable starting from room 0

Count connected components in an adjacency matrix

Determine if all courses can be finished with prerequisites

Return a valid course order when possible

Find minutes until all fresh oranges rot

Find time for all nodes to receive signal from source

Find cheapest cost with at most K stops

Build insert/search/startsWith on a trie of characters

Support addWord and search with wildcard dot matching

Replace words in a sentence by the shortest dictionary root

Return up to 3 lexicographically sorted suggestions while typing each prefix

Implement a stream checker that detects any suffix matching inserted words

Find all words in a board using trie-guided DFS

Minimize encoded length by merging shared suffixes in a trie

Implement buildDict + search allowing one character mismatch

Use bitwise trie to maximize xor value

Find the longest word that can be built one character at a time

Return the first index where needle appears in haystack, or -1

Find the longest prefix shared by all strings in an array

Return the length of the final word in a string

Count substrings with equal consecutive 0s and 1s

Parse a string into a 32-bit signed integer with clamping

Multiply two non-negative integer strings without converting to big integers

Format words into fully justified lines of width maxWidth

Count all palindromic substrings in a string

Find the longest palindromic substring

Compute minimum operations to convert word1 to word2

Implement regex matching with . and * for full-string match

Given a sorted array of integers and a target, return the index of the target or -1 if not found

Given a sorted array and a target, return the index if found or where it would be inserted to keep sorted order

Given a sorted array, find the starting and ending position of a target value. Return [-1, -1] if not found

A sorted array has been rotated at some pivot. Search for a target value in O(log n) time

Find the minimum element in a sorted array that has been rotated

Find any element that is strictly greater than its neighbors. nums[-1] = nums[n] = -infinity

Given a version control system where all versions after a bad version are bad, find the first bad version

Koko can eat bananas at speed k per hour. Given piles and h hours, find the minimum k to eat all bananas in time

Find the least weight capacity of a ship so that all packages can be shipped within d days (packages must stay in order)

Split an array into k non-empty continuous subarrays to minimize the largest subarray sum

Search a target in a rotated sorted array that may include duplicates

Find the index of the peak element in a mountain array (strictly increasing then decreasing)

Search for a target in a matrix where each row is sorted and first element of each row is greater than last element of previous row

Find the median of two sorted arrays in O(log(min(m,n))) time

Search for a target in a sorted matrix where each row and each column is sorted ascending

Find the smallest divisor such that sum of ceil(nums[i]/divisor) is within threshold

Pick m bouquets of k adjacent blooms, minimizing flowering day

Place m balls in baskets to maximize minimum distance

Design a key-value store that supports set(key, value, timestamp) and get(key, timestamp) returning value with largest timestamp <= given timestamp

Reverse a singly linked list in-place using three pointers

Merge two sorted linked lists into one sorted list

Detect if a linked list has a cycle using constant space

Find the middle node of a linked list in a single pass

Remove the nth node from the end of a linked list in one pass

Add two numbers represented as linked lists with digits in reverse order

Reorder list L0->L1->...->Ln to L0->Ln->L1->Ln-1->...

Swap every two adjacent nodes by rewiring pointers (not just swapping values)

Deep copy a linked list where each node has a next and a random pointer

Reverse the nodes of a linked list k at a time and return the modified list

Merge k sorted linked lists into one sorted linked list using divide and conquer

Implement an LRU Cache with O(1) get and put using a doubly linked list and hash map

Implement bubble sort to sort an array in ascending order

Implement insertion sort — build sorted array one element at a time

Implement merge sort using divide-and-conquer

Implement quicksort with partition — the most important sort for interviews

Check if two strings are anagrams by sorting and comparing

Merge all overlapping intervals — classic FAANG sorting problem

Can a person attend all meetings? Check for overlapping intervals

Find minimum number of conference rooms needed

Arrange numbers to form the largest possible number

Sort characters by how often they appear, most frequent first

Sort array according to the order defined by another array

Move all even numbers before odd numbers

Find the kth largest element using QuickSelect (partition)

Insert a new interval and merge if necessary

Find minimum number of intervals to remove for no overlaps