Graph Deep Copy Medium Given a reference to a node within an undirected graph, create a deep copy (clone) of the graph. The copied graph must be completely independent of the original one. This means you need to make new nodes for the copied graph instead of reusing any nodes from the original graph. Example: Constraints: Count […]
Tries
Design a Trie Medium Design and implement a trie data structure that supports the following operations: Example: Explanation: Constraints: Insert and Search Words with Wildcards Medium Design and implement a data structure that supports the following operations: Example: Explanation: Constraints: Find All Words on a Board Hard Given a 2D board of characters and an array of […]
Trees
Invert Binary Tree Easy Invert a binary tree and return its root. When a binary tree is inverted, it becomes the mirror image of itself. Example: Balanced Binary Tree Validation Easy Determine if a binary tree is height-balanced, meaning no node’s left subtree and right subtree have a height difference greater than 1. Example: Rightmost Nodes of […]
Prefix Sums
Sum Between Range Easy Given an integer array, write a function which returns the sum of values between two indexes. Example: Constraints: K-Sum Subarrays Medium Find the number of subarrays in an integer array that sum to k. Example: Product Array Without Current Element Medium Given an array of integers, return an array res so that res[i] is equal […]
Intervals
Merge Overlapping Intervals Medium Merge an array of intervals so there are no overlapping intervals, and return the resultant merged intervals. Example: Constraints: Identify All Interval Overlaps Medium Return an array of all overlaps between two arrays of intervals; intervals1 and intervals2. Each individual interval array is sorted by start value, and contains no overlapping intervals within itself. Example: Constraints: Largest […]
Heaps
K Most Frequent Strings Medium Find the k most frequently occurring strings in an array, and return them sorted by frequency in descending order. If two strings have the same frequency, sort them in lexicographical order. Example: Explanation: The strings “go” and “byte” appear the most frequently, with frequencies of 3 and 2, respectively. Constraints: Combine Sorted […]
Stacks
Valid Parenthesis Expression Easy Given a string representing an expression of parentheses containing the characters ‘(‘, ‘)’, ‘[‘, ‘]’, ‘{‘, or ‘}’, determine if the expression forms a valid sequence of parentheses. A sequence of parentheses is valid if every opening parenthesis has a corresponding closing parenthesis, and no closing parenthesis appears before its matching opening parenthesis. Example 1: Example 2: Explanation: […]
Binary Search
Find the Insertion Index Easy You are given a sorted array that contains unique values, along with an integer target. Example 1: Example 2: Explanation: 6 would be inserted at index 4 to be positioned between 5 and 7: [1, 2, 4, 5, 6, 7, 8, 9]. First and Last Occurrences of a Number Medium Given […]
Sliding Window
Substring Anagrams Medium Given two strings, s and t , both consisting of lowercase English letters, return the number of substrings in s that are anagrams of t. An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. Example: Explanation: There is an anagram of t starting at index 1 (“caabab”) […]
Fast And Slow Pointers
Linked List Loop Easy Given a singly linked list, determine if it contains a cycle. A cycle occurs if a node’s next pointer references an earlier node in the linked list, causing a loop. Example: Linked List Midpoint Easy Given a singly linked list, find and return its middle node. If there are two middle nodes, return […]









