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 […]
Linked Lists
Linked List Reversal Easy Reverse a singly linked list. Example: Remove the Kth Last Node From a Linked List Medium Return the head of a singly linked list after removing the kth node from the end of it. Example: Constraints: Linked List Intersection Easy Return the node where two singly linked lists intersect. If the linked […]
Hash Maps And Sets
Pair Sum – Unsorted Easy Given an array of integers, return the indexes of any two numbers that add up to a target. The order of the indexes in the result doesn’t matter. If no pair is found, return an empty array. Example: Explanation: nums[0] + nums[2] = -1 + 4 = 3 Constraints: Verify Sudoku Board […]









