leetcode-solutions icon indicating copy to clipboard operation
leetcode-solutions copied to clipboard

My solutions to Leetcode Problems

LeetCode solutions

My solutions to Leetcode Problems

  • All are AC solutions
  • Very few will have comments, because I wrote them for myself. But raise an issue if you want to understand more about a solution, and I will add an explanation
  • There is a small chance that a handful of solutions are not mine, because I sometimes submit solutions that my students ask me to debug. Raise an issue and I will remove it

Thanks to world177/Leetcode-Downloader-for-Submissions for bulk download.

Problems by tags

Array scanning

  • Apply operations to make string empty
  • Count the number of special characters ii
  • Dota2 senate
  • Maximum enemy forts that can be captured
  • Maximum value of an ordered triplet i
  • Maximum value of an ordered triplet ii
  • Minimum operations to maximize last elements in arrays
  • Minimum right shifts to sort the array
  • Monotonic array
  • Number of laser beams in a bank
  • Remove colored pieces if both neighbors are the same color
  • Separate black and white balls
  • Smallest missing integer greater than sequential prefix sum
  • Sum of absolute differences in a sorted array
  • The employee that worked on the longest task

Contiguous region

  • Arithmetic slices
  • Check if all 1s are at least length k places away
  • Consecutive characters
  • Count alternating subarrays
  • Count binary substrings
  • Count number of homogenous substrings
  • Distribute candies
  • Find all good indices
  • Find if array can be sorted
  • Find longest special substring that occurs thrice i
  • Find longest special substring that occurs thrice ii
  • Find the longest balanced substring of a binary string
  • Invalid transactions
  • Largest submatrix with rearrangements
  • Length of the longest alphabetical continuous substring
  • Longer contiguous segments of ones than zeros
  • Longest alternating subarray
  • Longest even odd subarray with threshold
  • Longest mountain in array
  • Longest non decreasing subarray from two arrays
  • Longest subarray with maximum bitwise and
  • Longest substring of all vowels in order
  • Longest turbulent subarray
  • Max consecutive ones
  • Maximal rectangle
  • Maximize area of square hole in grid
  • Maximum ascending subarray sum
  • Maximum product subarray
  • Minimum cost to make all characters equal
  • Minimum time to make rope colorful
  • Number of zero filled subarrays
  • Reduce array size to the half
  • The number of weak characters in the game

From both ends of array

  • Beautiful towers ii
  • Best time to buy and sell stock iii
  • Candy
  • Count palindromic subsequences
  • Count the number of incremovable subarrays i
  • Count the number of incremovable subarrays ii
  • Find all good indices
  • Find the distinct difference array
  • Largest plus sign
  • Left and right sum differences
  • Maximize distance to closest person
  • Maximize win from two segments
  • Maximum building height
  • Minimum average difference
  • Minimum cost to make all characters equal
  • Minimum cost to make array equal
  • Minimum index of a valid split
  • Minimum number of flips to make the binary string alternating
  • Minimum remove to make valid parentheses
  • Minimum sum of mountain triplets i
  • Minimum sum of mountain triplets ii
  • Partition array into disjoint intervals
  • Product of array except self
  • Subsequence with the minimum score
  • Sum of distances
  • Take k of each character from left and right
  • Unique length 3 palindromic subsequences

Element exclusion

  • Construct product matrix
  • Maximum or

In-place modification

  • Duplicate zeros
  • Find all duplicates in an array
  • Merge sorted array
  • Move zeroes
  • Remove all adjacent duplicates in string
  • Remove duplicates from sorted array
  • Remove duplicates from sorted array ii
  • Remove element
  • Reverse vowels of a string

Location of previous element with bit value

  • Minimum sum of values by dividing array

Location of previous element with same value

  • Count the number of good partitions
  • Count unique characters of all substrings of a given string
  • Execution of all suffix instructions staying in a grid
  • Largest substring between two equal characters
  • Maximize the number of partitions after operations
  • Number of subarrays with bounded maximum
  • Number of ways to divide a long corridor
  • Shortest subarray with or at least k i
  • Shortest subarray with or at least k ii
  • Split array into maximum number of subarrays
  • Subarrays distinct element sum of squares i
  • Subarrays distinct element sum of squares ii
  • Substring with largest variance
  • Ways to split array into good subarrays

Modify element with index

  • Best sightseeing pair

Right to left

  • Execution of all suffix instructions staying in a grid
  • Find the original array of prefix xor
  • Jump game ii
  • Jump game vi
  • Largest element in an array after merge operations
  • Largest odd number in string
  • Longest binary subsequence less than or equal to k
  • Maximize the number of partitions after operations
  • Minimum operations to collect elements
  • Minimum operations to make a special number
  • Minimum replacements to sort the array
  • Plus one
  • Smallest subarrays with maximum bitwise or
  • Solving questions with brainpower
  • The number of weak characters in the game
  • Using a robot to print the lexicographically smallest string
  • Visit array positions to maximize score

Averaging from total and count

  • Average of levels in binary tree
  • Count nodes equal to average of subtree
  • Design underground system
  • Find the grid of region average
  • Finding mk average
  • Minimum average difference

Backtracking

  • All paths from source to target
  • All possible full binary trees
  • Beautiful arrangement
  • Combination sum
  • Combination sum iii
  • Expression add operators
  • Find the punishment number of an integer
  • Generate parentheses
  • Maximum number of groups getting fresh donuts
  • Maximum score words formed by letters
  • N queens
  • Number of valid clock times
  • Partition to k equal sum subsets

Minimum option optimisation

  • Sudoku solver

Push and pop for efficient state update

  • Combinations
  • Path sum ii
  • Path sum iii
  • Path with maximum gold
  • Reconstruct itinerary
  • Word search ii

Binary lifting

  • Maximize value of function in a ball passing game
  • Minimum edge weight equilibrium queries in a tree
  • Prison cells after n days

Binary search

  • Binary search
  • Capacity to ship packages within d days
  • Construct binary search tree from preorder traversal
  • Count subarrays with score less than k
  • Data stream as disjoint intervals
  • Design movie rental system
  • Dungeon game
  • Earliest second to mark indices i
  • Earliest second to mark indices ii
  • Find building where alice and bob can meet
  • Find first and last position of element in sorted array
  • Find in mountain array
  • Find k closest elements
  • Find right interval
  • Find smallest letter greater than target
  • Find the duplicate number
  • Find the longest valid obstacle course at each position
  • Find the maximum number of marked indices
  • Find the smallest divisor given a threshold
  • Find the sum of subsequence powers
  • First bad version
  • Guess number higher or lower
  • H index
  • H index ii
  • House robber iv
  • K th smallest prime fraction
  • Koko eating bananas
  • Kth smallest amount with single denomination combination
  • Kth smallest element in a sorted matrix
  • Kth smallest number in multiplication table
  • Longest palindromic substring
  • Longest subsequence with limited sum
  • Maximize the minimum powered city
  • Maximum distance between a pair of values
  • Maximum number of alloys
  • Maximum number of removable characters
  • Maximum number of robots within budget
  • Maximum running time of n computers
  • Maximum tastiness of candy basket
  • Maximum value at a given index in a bounded array
  • Maximum xor of two numbers in an array
  • Median of two sorted arrays
  • Minimize maximum of array
  • Minimize the maximum difference of pairs
  • Minimum cost for tickets
  • Minimum operations to make all array elements equal
  • Minimum speed to arrive on time
  • Minimum time to complete trips
  • Minimum time to repair cars
  • Nth magical number
  • Partition array such that maximum difference is k
  • Peak index in a mountain array
  • Prime subtraction operation
  • Split array largest sum

C++ set

  • 132 pattern
  • Closest room
  • Contains duplicate iii
  • Count of range sum
  • Maximum balanced subsequence sum
  • Maximum number of points from grid queries
  • Maximum sum queries
  • Minimum absolute difference between elements with constraint
  • Minimum absolute sum difference
  • Minimum reverse operations
  • My calendar i
  • Online majority element in subarray
  • Random pick with weight
  • Random point in non overlapping rectangles
  • Snapshot array

Exponential-binary search

  • Maximum number that sum of the prices is less than or equal to k

Prefix sum

  • Delivering boxes from storage to ports
  • Max sum of rectangle no larger than k
  • Random pick with weight
  • Random point in non overlapping rectangles

Bitwise operation

  • Apply bitwise operations to make strings equal
  • Apply operations on array to maximize sum of squares
  • Binary watch
  • Bitwise and of numbers range
  • Check if a string contains all binary codes of size k
  • Check if bitwise or has trailing zeros
  • Cinema seat allocation
  • Complement of base 10 integer
  • Concatenation of consecutive binary numbers
  • Count pairs with xor in a range
  • Counting bits
  • Cycle length queries in a tree
  • Determine if string halves are alike
  • Divide two integers
  • Find a good subset of the matrix
  • Find a value of a mysterious function closest to target
  • Find if array can be sorted
  • Find the k or of an array
  • Find xor sum of all pairs bitwise and
  • Form smallest number from two digit arrays
  • Gray code
  • Hamming distance
  • K th symbol in grammar
  • Longest uncommon subsequence ii
  • Maximum length of a concatenated string with unique characters
  • Maximum number of achievable transfer requests
  • Maximum or
  • Maximum product of word lengths
  • Maximum rows covered by columns
  • Maximum strength of a group
  • Maximum strong pair xor i
  • Maximum strong pair xor ii
  • Maximum xor after operations
  • Maximum xor for each query
  • Minimize xor
  • Minimum flips to make a or b equal to c
  • Minimum impossible or
  • Minimum one bit operations to make integers zero
  • Minimum operations to form subsequence with target sum
  • Minimum operations to make the integer zero
  • Minimum operations to reduce an integer to 0
  • Minimum sum of values by dividing array
  • Minimum xor sum of two arrays
  • Missing number
  • Non decreasing subsequences
  • Non negative integers without consecutive ones
  • Number complement
  • Number of 1 bits
  • Number of even and odd bits
  • Number of excellent pairs
  • Number of possible sets of closing branches
  • Power of four
  • Power of two
  • Powx n
  • Prison cells after n days
  • Range product queries of powers
  • Remove duplicate letters
  • Remove invalid parentheses
  • Score after flipping matrix
  • Shortest path to get all keys
  • Shortest subarray with or at least k i
  • Shortest subarray with or at least k ii
  • Smallest subarrays with maximum bitwise or
  • Smallest sufficient team
  • Special permutations
  • Split array into maximum number of subarrays
  • String compression ii
  • Sum of values at indices with k set bits
  • Unique length 3 palindromic subsequences
  • Utf 8 validation

Build result bit-by-bit

  • Find xor beauty of array
  • Maximum xor of two numbers in an array
  • Minimize or of remaining elements using operations
  • Minimum number of flips to convert binary matrix to zero matrix

Self-inverse property of xor

  • Bitwise xor of all pairings
  • Count pairs of points with distance k
  • Count paths that can form a palindrome in a tree
  • Count the number of beautiful subarrays
  • Find the maximum sum of node values
  • Find the original array of prefix xor
  • Maximum xor product
  • Minimum number of operations to make array xor equal to k
  • Neighboring bitwise xor
  • Number of wonderful substrings
  • Pseudo palindromic paths in a binary tree
  • Substring xor queries

Brute force enumeration

Combinatorial

  • Fair distribution of cookies
  • Iterator for combination
  • Longest uncommon subsequence ii
  • Matchsticks to square
  • Maximum length of a concatenated string with unique characters
  • Maximum number of achievable transfer requests
  • Maximum rows covered by columns
  • Maximum strength of a group
  • Minimum moves to spread stones over grid
  • N queens
  • N queens ii
  • Non decreasing subsequences
  • Number of possible sets of closing branches
  • Permutations
  • Probability of a two boxes having the same number of distinct balls
  • Remove invalid parentheses
  • Shortest string that contains three strings

Elementwise processing using a vector

  • Kth smallest amount with single denomination combination
  • Letter case permutation
  • Letter combinations of a phone number
  • Minimum number of flips to convert binary matrix to zero matrix
  • Numbers with same consecutive differences

Case-by-case analysis

  • Make number of distinct characters equal

ChatGPT

  • All possible full binary trees
  • Can make arithmetic progression from sequence
  • Combinations
  • Design parking system
  • Longest arithmetic subsequence
  • Longest arithmetic subsequence of given difference
  • Maximum level sum of a binary tree
  • Minimum ascii delete sum for two strings
  • Minimum flips to make a or b equal to c
  • Minimum size subarray sum
  • Number of provinces
  • Peak index in a mountain array
  • Predict the winner
  • Stone game iii
  • Strange printer
  • Time needed to inform all employees

Fixed

  • Frog jump
  • Number of music playlists

Concurrency

  • Building h2o
  • Fizz buzz multithreaded
  • Print foobar alternately
  • Print in order
  • Print zero even odd

Construction

  • Beautiful arrangement ii
  • Beautiful array

Counting elements in array

  • 3sum with multiplicity
  • Determine if two strings are close
  • Find all anagrams in a string
  • Intersection of two arrays ii
  • Largest palindromic number
  • Longest palindrome
  • Minimum penalty for a shop

Deque

Monotonic deque

  • Find maximum non decreasing array length
  • Maximum number of robots within budget

Design data structure

  • Construct quad tree
  • Data stream as disjoint intervals
  • Design a food rating system
  • Design a number container system
  • Design add and search words data structure
  • Design authentication manager
  • Design browser history
  • Design circular queue
  • Design hashmap
  • Design hashset
  • Design memory allocator
  • Design movie rental system
  • Design parking system
  • Design underground system
  • Encode and decode tinyurl
  • Find consecutive integers from a data stream
  • Frequency tracker
  • Implement trie prefix tree
  • Insert delete getrandom o1
  • Iterator for combination
  • Lfu cache
  • Longest uploaded prefix
  • Lru cache
  • Maximum frequency stack
  • Min stack
  • Number of recent calls
  • Online majority element in subarray
  • Peeking iterator
  • Random pick with weight

Interconversion

  • Implement queue using stacks
  • Implement stack using queues

Persistent

  • Snapshot array

Disjoint set union

  • Accounts merge
  • Checking existence of edge length limited paths
  • Find all people with secret
  • Find critical and pseudo critical edges in minimum spanning tree
  • Find the safest path in a grid
  • Greatest common divisor traversal
  • Largest component size by common factor
  • Last day where you can still cross
  • Lexicographically smallest equivalent string
  • Maximum segment sum after removals
  • Min cost to connect all points
  • Minimum cost walk in weighted graph
  • Number of good paths
  • Number of islands
  • Rank transform of a matrix
  • Redundant connection
  • Remove max number of edges to keep graph fully traversable
  • Satisfiability of equality equations
  • Similar string groups
  • Sum of subarray minimums

Divide and conquer

  • Reveal cards in increasing order

Dynamic programming

  • Arithmetic slices ii subsequence
  • Beautiful towers ii
  • Best team with no conflicts
  • Best time to buy and sell stock iii
  • Best time to buy and sell stock with cooldown
  • Binary trees with factors
  • Burst balloons
  • Cheapest flights within k stops
  • Check if it is possible to split array
  • Check if there is a valid partition for the array
  • Climbing stairs
  • Concatenated words
  • Count number of ways to place houses
  • Count palindromic subsequences
  • Count square submatrices with all ones
  • Count unique characters of all substrings of a given string
  • Count vowels permutation
  • Count ways to build good strings
  • Decode ways
  • Decode ways ii
  • Delete and earn
  • Domino and tromino tiling
  • Edit distance
  • Extra characters in a string
  • Fibonacci number
  • Find all possible stable binary arrays i
  • Find all possible stable binary arrays ii
  • Frog jump
  • House robber
  • Jump game
  • Jump game ii
  • Longest arithmetic subsequence
  • Longest arithmetic subsequence of given difference
  • Longest string chain
  • Longest unequal adjacent groups subsequence i
  • Maximize the number of partitions after operations
  • Maximum alternating subsequence sum
  • Maximum balanced subsequence sum
  • Maximum deletions on a string
  • Maximum number of jumps to reach the last index
  • Maximum strictly increasing cells in a matrix
  • Min cost climbing stairs
  • Minimum cost for tickets
  • Minimum cost to convert string ii
  • Minimum cost to cut a stick
  • Minimum cost to make all characters equal
  • Minimum cost to make array equal
  • Minimum cost to split an array
  • Minimum difficulty of a job schedule
  • Minimum increment operations to make array beautiful
  • Minimum penalty for a shop
  • Minimum sideway jumps
  • Minimum time to remove all cars containing illegal goods
  • New 21 game
  • Number of distinct roll sequences
  • Number of music playlists
  • Number of ways to rearrange sticks with k sticks visible
  • Number of ways to reorder array to get same bst
  • Paint house iii
  • Palindrome partitioning ii
  • Palindrome partitioning iii
  • Palindrome partitioning iv
  • Partition array for maximum sum
  • Partition string into substrings with values at most k
  • Pascals triangle
  • Remove boxes
  • Restore ip addresses
  • Restore the array
  • Solving questions with brainpower
  • Sorting three groups
  • Soup servings
  • Split array into maximum number of subarrays
  • Stone game iii
  • Strange printer
  • The number of beautiful subsets
  • Ways to express an integer as sum of powers

Array reuse

  • Champagne tower
  • Cherry pickup ii
  • Coin change
  • Coin change 2
  • Decremental string concatenation
  • Delete operation for two strings
  • Distinct subsequences
  • Find the sum of subsequence powers
  • Find the sum of the power of all subsequences
  • Freedom trail
  • Interleaving string
  • K inverse pairs array
  • Knight dialer
  • Length of the longest subsequence that sums to target
  • Longest binary subsequence less than or equal to k
  • Longest ideal subsequence
  • Longest palindromic subsequence
  • Make array strictly increasing
  • Maximize consecutive elements in an array after modification
  • Maximum length of repeated subarray
  • Maximum number of points with cost
  • Maximum score from performing multiplication operations
  • Maximum strength of k disjoint subarrays
  • Maximum value of k coins from piles
  • Minimum additions to make valid string
  • Minimum falling path sum
  • Minimum falling path sum ii
  • Minimum insertion steps to make a string palindrome
  • Minimum number of coins for fruits
  • Minimum number of operations to satisfy conditions
  • Minimum number of refueling stops
  • Minimum path cost in a grid
  • Minimum path sum
  • Minimum skips to arrive at meeting on time
  • Minimum sum of values by dividing array
  • Minimum time to make array sum at most x
  • Minimum total distance traveled
  • N th tribonacci number
  • Number of great partitions
  • Number of strings which can be rearranged to contain substring
  • Number of ways of cutting a pizza
  • Number of ways to earn points
  • Number of ways to form a target string given a dictionary
  • Number of ways to stay in the same place after some steps
  • Painting the walls
  • Partition equal subset sum
  • Pascals triangle ii
  • Paths in matrix whose sum is divisible by k
  • Prison cells after n days
  • String compression ii
  • Tallest billboard
  • Visit array positions to maximize score

Auxiliary array

  • Best time to buy and sell stock iv
  • Best time to buy and sell stock with transaction fee
  • Count of integers
  • Minimum changes to make k semi palindromes
  • Minimum one bit operations to make integers zero
  • Number of beautiful partitions
  • Number of people aware of a secret

Binary lifting

  • Maximize value of function in a ball passing game

Complexity reduction with algebra

  • Power of heroes

Construction

  • Find the string with lcp

Cyclic array

  • Collecting chocolates
  • Freedom trail
  • House robber ii
  • Maximum sum circular subarray
  • Minimum number of flips to make the binary string alternating
  • Minimum size subarray in infinite array
  • Pizza with 3n slices

Digits

  • Count of integers
  • Count special integers
  • Count stepping numbers in range
  • Count the number of powerful integers
  • Maximum number that sum of the prices is less than or equal to k
  • Non negative integers without consecutive ones
  • Number of beautiful integers in the range
  • Number of digit one
  • Numbers at most n given digit set

Element with special meaning

  • Make array strictly increasing

Graph-like state transitions

  • Knight dialer
  • Knight probability in chessboard
  • Maximum number of non overlapping palindrome substrings
  • Minimum additions to make valid string
  • Number of strings which can be rearranged to contain substring
  • Number of ways to paint n 3 grid
  • Special permutations

Grid

  • Maximum number of moves in a grid
  • Paths in matrix whose sum is divisible by k

Intervals

  • Maximize the profit as the salesman
  • Maximum number of events that can be attended ii
  • Maximum profit in job scheduling

Knapsack

  • Coin change
  • Coin change 2
  • Count all possible routes
  • Count of sub multisets with bounded sum
  • Find the sum of the power of all subsequences
  • Length of the longest subsequence that sums to target
  • Maximum value of k coins from piles
  • Number of great partitions
  • Number of ways to earn points
  • Ones and zeroes
  • Partition equal subset sum
  • Tallest billboard

State modification

  • Painting the walls

Length-wise processing

  • Apply operations to make two strings equal

Longest common subsequence

  • Delete operation for two strings
  • Longest common subsequence
  • Max dot product of two subsequences
  • Maximum length of repeated subarray
  • Minimum ascii delete sum for two strings

Longest increasing subsequence

  • Find the longest valid obstacle course at each position
  • Longest increasing subsequence
  • Number of longest increasing subsequence

Matrix exponentiation

  • String transformation

Memoised recursion

  • Build array where you can find the maximum exactly k comparisons
  • Combination sum iv
  • Maximum number of operations with the same score ii
  • Minimum number of days to eat n oranges
  • Number of dice rolls with target sum
  • Out of boundary paths
  • Palindrome partitioning
  • Partition string into minimum beautiful substrings
  • Partition to k equal sum subsets
  • Predict the winner

Monotonic stack/deque

  • Find maximum non decreasing array length
  • Minimum difficulty of a job schedule

Number theory

  • Count the number of ideal arrays
  • Largest divisible subset

Partial bottom-up

  • Decremental string concatenation
  • String compression ii
  • Tallest billboard

Reconstructing optimal solution

  • Longest unequal adjacent groups subsequence ii

Segment tree

  • Count increasing quadruplets
  • Delivering boxes from storage to ports

Subsets

  • Construct smallest number from di string
  • Count the number of square free subsets
  • Find the shortest superstring
  • Maximize score after n operations
  • Minimum xor sum of two arrays
  • Smallest sufficient team
  • Special permutations

Topological sort

  • Largest color value in a directed graph

Trees

  • All nodes distance k in binary tree
  • Count number of possible root nodes
  • Count valid paths in a tree
  • Cousins in binary tree ii
  • Diameter of binary tree
  • Difference between maximum and minimum price sum
  • Employee importance
  • Find duplicate subtrees
  • Find number of coins to place in tree nodes
  • Height of binary tree after subtree removal queries
  • House robber iii
  • Longest path with different adjacent characters
  • Longest univalue path
  • Maximum number of k divisible components
  • Maximum points after collecting coins from all nodes
  • Maximum score after applying operations on a tree
  • Minimize the total price of the trips
  • Minimum cost to change the final value of expression
  • Minimum edge reversals so every node is reachable
  • Minimum score after removals on a tree
  • Most profitable path in a tree

DP over children

  • Count pairs of connectable servers in a weighted tree network
  • Find the maximum sum of node values

Dynamic update of left and right neighbours

  • Robot collisions
  • Sum of imbalance numbers of all subarrays

Encoding and decoding

  • Encode and decode tinyurl

Flattening

  • Flatten a multilevel doubly linked list
  • Flatten binary tree to linked list
  • Flatten nested list iterator

Formatted output

  • Binary watch
  • Integer to english words
  • Integer to roman

Graph theory

  • Maximal network rank

Addition of auxiliary vertices

  • Greatest common divisor traversal
  • Shortest path to get all keys

Bipartite graph

  • Divide nodes into the maximum number of groups

Breadth first search

  • 01 matrix
  • Amount of time for binary tree to be infected
  • As far from land as possible
  • Bus routes
  • Detonate the maximum bombs
  • Divide nodes into the maximum number of groups
  • Find the safest path in a grid
  • Jump game iv
  • Maximum level sum of a binary tree
  • Minimum genetic mutation
  • Minimum moves to capture the queen
  • Minimum number of visited cells in a grid
  • Minimum operations to convert number
  • Minimum reverse operations
  • Nearest exit from entrance in maze
  • Open the lock
  • Pacific atlantic water flow
  • Shortest bridge
  • Shortest path to get all keys
  • Shortest path with alternating colors
  • Special permutations

Bridges/Articulation points

  • Critical connections in a network

Cycle detection

  • Find closest node to given two nodes
  • Happy number

Degree counting

  • Add edges to make degrees of all nodes even
  • Collect coins in a tree
  • Find champion i
  • Find champion ii
  • Find the town judge
  • Minimum number of vertices to reach all nodes
  • Restore the array from adjacent pairs
  • Validate binary tree nodes

Depth first search

  • Amount of time for binary tree to be infected
  • Count number of possible root nodes
  • Count pairs of connectable servers in a weighted tree network
  • Count paths that can form a palindrome in a tree
  • Count valid paths in a tree
  • Create components with same value
  • Critical connections in a network
  • Delete nodes and return forest
  • Detect cycles in 2d grid
  • Difference between maximum and minimum price sum
  • Employee importance
  • Find if path exists in graph
  • Find number of coins to place in tree nodes
  • Find the maximum sum of node values
  • Jump game iii
  • Keys and rooms
  • Longest increasing path in a matrix
  • Longest path with different adjacent characters
  • Maximum number of k divisible components
  • Maximum points after collecting coins from all nodes
  • Maximum score after applying operations on a tree
  • Minimize the total price of the trips
  • Minimum edge reversals so every node is reachable
  • Minimum edge weight equilibrium queries in a tree
  • Minimum fuel cost to report to the capital
  • Minimum number of operations to sort a binary tree by level
  • Minimum score after removals on a tree
  • Minimum score of a path between two cities
  • Minimum time to collect all apples in a tree
  • Most profitable path in a tree
  • Number of increasing paths in a grid
  • Number of nodes in the sub tree with the same label
  • Reachable nodes with restrictions
  • Reorder routes to make all paths lead to the city zero
  • Shortest cycle in a graph
  • Time needed to inform all employees
  • Validate binary tree nodes

Colouring

  • Is graph bipartite
  • Possible bipartition

Component decomposition

  • Count the number of complete components
  • Count unreachable pairs of nodes in an undirected graph
  • Divide nodes into the maximum number of groups
  • Evaluate division
  • Most stones removed with same row or column
  • Number of islands
  • Number of operations to make network connected
  • Number of provinces

Flood fill

  • Count sub islands
  • Flood fill
  • Making a large island
  • Max area of island
  • Maximum number of fish in a grid
  • Number of closed islands
  • Number of enclaves
  • Shortest bridge

Iterative

  • Find eventual safe states

Tree diameter

  • Minimum height trees

Dijkstra's algorithm

  • Design graph with shortest path calculator
  • Minimum cost of a path with special roads
  • Minimum time to visit a cell in a grid
  • Minimum time to visit disappearing nodes
  • Modify graph edge weights
  • Network delay time
  • Number of ways to arrive at destination
  • Path with maximum probability
  • Path with minimum effort
  • Reachable nodes in subdivided graph

Forward and backward

  • Find edges in shortest paths

Directed acyclic graph

  • All paths from source to target
  • Find champion i
  • Find champion ii

Floyd-Warshall algorithm

  • Minimum cost to convert string i
  • Minimum cost to convert string ii
  • Number of possible sets of closing branches

Iterative leaf removal

  • Collect coins in a tree

Lewel-wise processing

  • Maximum strictly increasing cells in a matrix

Lowest common ancestor

  • Minimum edge weight equilibrium queries in a tree

Minimum spanning tree

  • Find critical and pseudo critical edges in minimum spanning tree
  • Min cost to connect all points

Multi source search

  • As far from land as possible
  • Find the safest path in a grid
  • Shortest bridge
  • Shortest path with alternating colors

Prim's algorithm

  • Maximum number of points from grid queries

Reuse visited array

  • Divide nodes into the maximum number of groups
  • Shortest cycle in a graph

Single cycle graphs

  • Count the number of houses at a certain distance i
  • Count the number of houses at a certain distance ii

Single outdegree graphs

  • Count visited nodes in a directed graph
  • Destination city
  • Find closest node to given two nodes
  • Longest cycle in a graph
  • Node with highest edge score
  • Where will the ball fall

Topological sort

  • Build a matrix with conditions
  • Course schedule
  • Course schedule ii
  • Find eventual safe states
  • Maximum strictly increasing cells in a matrix

Dynamic Programming

  • Largest color value in a directed graph
  • Parallel courses iii

Greedy

  • Advantage shuffle
  • Append characters to string to make subsequence
  • Apple redistribution into boxes
  • Apply operations on array to maximize sum of squares
  • Apply operations to make all array elements equal to zero
  • Apply operations to maximize score
  • Assign cookies
  • Bag of tokens
  • Best time to buy and sell stock ii
  • Boats to save people
  • Candy
  • Course schedule iii
  • Determine the minimum sum of a k avoiding array
  • Divide array into arrays with max difference
  • Dota2 senate
  • Earliest possible day of full bloom
  • Earliest second to mark indices i
  • Earliest second to mark indices ii
  • Eliminate maximum number of monsters
  • Find polygon with the largest perimeter
  • Find the maximum number of marked indices
  • Find the minimum possible sum of a beautiful array
  • Find the value of the partition
  • Frog jump ii
  • Furthest building you can reach
  • Furthest point from origin
  • Gas station
  • Happy students
  • Is subsequence
  • Largest number
  • Least number of unique integers after k removals
  • Lexicographically smallest string after operations with constraint
  • Lexicographically smallest string after substring operation
  • Longest subsequence with limited sum
  • Make array zero by subtracting equal amounts
  • Make costs of paths equal in a binary tree
  • Make string a subsequence using cyclic increments
  • Maximize greatness of an array
  • Maximize happiness of selected children
  • Maximize the minimum powered city
  • Maximum bags with full capacity of rocks
  • Maximum element after decreasing and rearranging
  • Maximum ice cream bars
  • Maximum length of pair chain
  • Maximum matching of players with trainer
  • Maximum number of coins you can get
  • Maximum number of consecutive values you can make
  • Maximum number of groups entering a competition
  • Maximum number of groups with increasing length
  • Maximum number of integers to choose from a range i
  • Maximum odd binary number
  • Maximum palindromes after operations
  • Maximum performance of a team
  • Maximum product difference between two pairs
  • Maximum product of two elements in an array
  • Maximum spending after buying items
  • Maximum tastiness of candy basket
  • Maximum units on a truck
  • Maximum value after insertion
  • Maximum xor product
  • Mice and cheese
  • Minimize maximum pair sum in array
  • Minimize the maximum difference of pairs
  • Minimum amount of time to fill cups
  • Minimum array length after pair removals
  • Minimum cost to make array equal
  • Minimum deletions to make string k special
  • Minimum equal sum of two arrays after replacing zeros
  • Minimum levels to gain more points
  • Minimum money required before transactions
  • Minimum number of arrows to burst balloons
  • Minimum number of changes to make binary string beautiful
  • Minimum number of coins to be added
  • Minimum number of groups to create a valid assignment
  • Minimum number of increments on subarrays to form a target array
  • Minimum number of operations to make all array elements equal to 1
  • Minimum number of operations to make arrays similar
  • Minimum number of pushes to type word i
  • Minimum number of pushes to type word ii
  • Minimum number of taps to open to water a garden
  • Minimum operations to make a special number
  • Minimum operations to make array equal ii
  • Minimum operations to make median of array equal to k
  • Minimum operations to make the array increasing
  • Minimum processing time
  • Minimum rectangles to cover points
  • Minimum replacements to sort the array
  • Minimum score by changing two elements
  • Minimum sum of squared difference
  • Minimum time to complete all tasks
  • Minimum time to make array sum at most x
  • Minimum total cost to make arrays unequal
  • Minimum total distance traveled
  • Non overlapping intervals
  • Number of matching subsequences
  • Partition labels
  • Patching array
  • Prime subtraction operation
  • Put marbles in bags
  • Queue reconstruction by height
  • Rearrange array to maximize prefix score
  • Rearranging fruits
  • Reduce array size to the half
  • Reducing dishes
  • Remove adjacent almost equal characters
  • Remove duplicate letters
  • Remove k digits
  • Remove stones to minimize the total
  • Reorganize string
  • Replace question marks in string to minimize its value
  • Score after flipping matrix
  • Smallest missing non negative integer after operations
  • Split array largest sum
  • Split with minimum sum

Hashmap

  • Array of doubled pairs
  • Binary subarrays with sum
  • Brick wall
  • Check array formation through concatenation
  • Check distances between same letters
  • Cinema seat allocation
  • Clone graph
  • Contains duplicate ii
  • Contiguous array
  • Continuous subarray sum
  • Convert an array into a 2d array with conditions
  • Count anagrams
  • Count beautiful substrings i
  • Count beautiful substrings ii
  • Count complete subarrays in an array
  • Count number of bad pairs
  • Count number of distinct integers after reverse operations
  • Count pairs of points with distance k
  • Count pairs of similar strings
  • Count subarrays with median k
  • Count the number of beautiful subarrays
  • Count the number of good subarrays
  • Count the number of special characters ii
  • Delete and earn
  • Design hashmap
  • Destroy sequential targets
  • Determine if two strings are close
  • Difference of number of distinct values on diagonals
  • Distinct prime factors of product of array
  • Encode and decode tinyurl
  • Equal row and column pairs
  • Evaluate the bracket pairs of a string
  • Extra characters in a string
  • Find duplicate file in system
  • Find longest special substring that occurs thrice i
  • Find longest special substring that occurs thrice ii
  • Find maximum number of string pairs
  • Find missing and repeated values
  • Find mode in binary search tree
  • Find players with zero or one losses
  • Find subarrays with equal sum
  • Find the difference of two arrays
  • Find the distinct difference array
  • Find the length of the longest common prefix
  • Find the prefix common array of two arrays
  • Find words that can be formed by characters
  • Finding the users active minutes
  • First completely painted row or column
  • First letter to appear twice
  • First unique character in a string
  • Greatest english letter in upper and lower case
  • Group anagrams
  • Intersection of two arrays
  • Intersection of two arrays ii
  • Invalid transactions
  • Jewels and stones
  • K diff pairs in an array
  • Largest positive integer that exists with its negative
  • Length of longest subarray with at most k frequency
  • Longest arithmetic subsequence of given difference
  • Longest consecutive sequence
  • Longest nice subarray
  • Longest palindrome by concatenating two letter words
  • Longest square streak in an array
  • Longest uploaded prefix
  • Longest word in dictionary
  • Lru cache
  • Make number of distinct characters equal
  • Map sum pairs
  • Max number of k sum pairs
  • Max points on a line
  • Max sum of a pair with equal sum of digits
  • Maximum good subarray sum
  • Maximum number of integers to choose from a range i
  • Maximum number of pairs in array
  • Maximum population year
  • Maximum square area by removing fences from a field
  • Maximum sum of distinct subarrays with length k
  • Merge similar items
  • Minimize string length
  • Minimum amount of time to collect garbage
  • Minimum array length after pair removals
  • Minimum cost to convert string ii
  • Minimum cost to split an array
  • Minimum deletions to make character frequencies unique
  • Minimum number of operations to make array empty
  • Minimum number of steps to make two strings anagram
  • Minimum operations to collect elements
  • Minimum rounds to complete all tasks
  • Minimum total cost to make arrays unequal
  • Most frequent even element
  • Most popular video creator
  • Number of atoms
  • Number of black blocks
  • Number of distinct averages
  • Number of excellent pairs
  • Number of good pairs
  • Number of nodes in the sub tree with the same label
  • Number of wonderful substrings
  • Odd string difference
  • Optimal partition of string
  • Pairs of songs with total durations divisible by 60
  • Partition labels
  • Path crossing
  • Path sum iii
  • Permutation in string
  • Powerful integers
  • Prefix and suffix search
  • Rabbits in forest
  • Ransom note
  • Rearranging fruits
  • Reconstruct original digits from english
  • Redistribute characters to make all strings equal
  • Reduce array size to the half
  • Relocate marbles
  • Remove zero sum consecutive nodes from linked list
  • Reward top k students
  • Shortest uncommon substring in an array
  • Sliding subarray beauty
  • Smallest subarrays with maximum bitwise or
  • Subarray sums divisible by k
  • Substring xor queries
  • Sum of distances
  • Sum of matrix after queries
  • Sum of prefix scores of strings
  • Take k of each character from left and right

Coordinate compression

  • Design underground system
  • Distribute elements into two arrays ii

Counter

  • Apply operations to make string empty
  • Count elements with maximum frequency
  • Count substrings starting and ending with given character
  • Find the maximum number of elements in subset
  • Least number of unique integers after k removals
  • Maximum length substring with two occurrences
  • Maximum palindromes after operations
  • Minimize length of array using operations
  • Minimum deletions to make string k special
  • Minimum levels to gain more points
  • Minimum number of operations to satisfy conditions
  • Minimum number of pushes to type word i
  • Minimum number of pushes to type word ii
  • Minimum operations to write the letter y on a grid
  • Number of students unable to eat lunch
  • Replace question marks in string to minimize its value
  • Split the array
  • Subarrays with k different integers
  • Unique number of occurrences

Forward and backward

  • Find and replace pattern
  • Find the longest equal subarray
  • First unique number
  • Frequency tracker
  • Insert delete getrandom o1
  • Isomorphic strings
  • Most frequent ids

Group items

  • Find the longest equal subarray
  • Group the people given the group size they belong to
  • Jump game iv
  • Max pair sum in an array
  • Minimum seconds to equalize a circular array
  • Number of good paths
  • Remove letter to equalize frequency

Update using insert and delete

  • Finding pairs with a certain sum
  • Fraction to recurring decimal

Heuristic optimisation

  • Maximum number of groups getting fresh donuts

Integer operations on strings

  • Add binary
  • Add two numbers
  • Add two numbers ii
  • Complex number multiplication
  • Plus one

Intervals

  • Insert interval
  • Length of the longest valid substring
  • Maximum number of events that can be attended
  • Minimum number of taps to open to water a garden

2D

  • Rectangle area ii

Dynamic Programming

  • Maximize the profit as the salesman

Dynamic programming

With binary search

  • Maximum number of events that can be attended ii
  • Maximum profit in job scheduling

Endpoint sorting

  • Car pooling
  • Divide intervals into minimum number of groups
  • Minimum interval to include each query
  • My calendar iii
  • Number of flowers in full bloom
  • Rectangle area ii

Non-overlapping decomposition

  • Falling squares
  • Rectangle area ii

Overlap

  • Count days spent together
  • Count ways to group overlapping ranges
  • Determine if two events have conflict
  • Divide intervals into minimum number of groups
  • Find the largest area of square inside two rectangles
  • Interval list intersections
  • Minimum time to complete all tasks
  • My calendar iii
  • Non overlapping intervals
  • Number of flowers in full bloom
  • Palindrome rearrangement queries
  • Remove covered intervals
  • Split the array to make coprime products

Union

  • Data stream as disjoint intervals
  • Merge intervals

Linked list

Iteration

  • Add two numbers
  • Add two numbers ii
  • Convert binary number in a linked list to integer
  • Convert sorted list to binary search tree
  • Copy list with random pointer
  • Delete node in a linked list
  • Flatten a multilevel doubly linked list
  • Flatten binary tree to linked list
  • Insert greatest common divisors in linked list
  • Insertion sort list
  • Intersection of two linked lists
  • Linked list random node
  • Merge in between linked lists
  • Merge k sorted lists
  • Merge two sorted lists
  • Odd even linked list
  • Partition list
  • Reorder list

Slow and fast pointers

  • Delete the middle node of a linked list
  • Linked list cycle
  • Linked list cycle ii
  • Maximum twin sum of a linked list
  • Middle of the linked list
  • Remove nth node from end of list

Recursion

  • Double a number represented as a linked list
  • Flatten a multilevel doubly linked list
  • Maximum twin sum of a linked list
  • Palindrome linked list
  • Remove duplicates from sorted list ii
  • Remove linked list elements
  • Remove nodes from linked list
  • Remove zero sum consecutive nodes from linked list

Majority element

  • Majority element
  • Majority element ii
  • Minimum index of a valid split

Mathematics

  • Maximum number of consecutive values you can make

Advanced

  • Best position for a service centre

Basic

  • Alice and bob playing flower game
  • Angle between hands of a clock
  • Apply operations to make sum of array greater than or equal to k
  • Can make arithmetic progression from sequence
  • Construct the longest new string
  • Count of matches in tournament
  • Distribute money to maximum children
  • Find the maximum achievable number
  • Fraction to recurring decimal
  • Largest perimeter triangle
  • Minimum number of operations to make array empty
  • Poor pigs
  • Replace question marks in string to minimize its value
  • Strictly palindromic number
  • Sum of absolute differences in a sorted array

Closed form expressions

  • Calculate money in leetcode bank
  • Count anagrams
  • Count substrings starting and ending with given character
  • Count total number of colored cells
  • Distribute candies among children i
  • Distribute candies among children ii
  • Find the pivot integer
  • Maximum sum with exactly k elements
  • Maximum value at a given index in a bounded array
  • Minimum operations to make array equal
  • Power of heroes

Combinatorics

  • 3sum with multiplicity
  • Arithmetic slices ii subsequence
  • Binary trees with factors
  • Build array where you can find the maximum exactly k comparisons
  • Count all possible routes
  • Count all valid pickup and delivery options
  • Count anagrams
  • Count beautiful substrings i
  • Count beautiful substrings ii
  • Count collisions of monkeys on a polygon
  • Count good numbers
  • Count k subsequences of a string with maximum beauty
  • Count nice pairs in an array
  • Count number of bad pairs
  • Count number of homogenous substrings
  • Count number of ways to place houses
  • Count pairs of nodes
  • Count pairs of similar strings
  • Count sorted vowel strings
  • Count special integers
  • Count substrings starting and ending with given character
  • Count the number of fair pairs
  • Count the number of good partitions
  • Count the number of houses at a certain distance i
  • Count the number of houses at a certain distance ii
  • Count the number of ideal arrays
  • Count the number of infection sequences
  • Count unreachable pairs of nodes in an undirected graph
  • Count ways to group overlapping ranges
  • Domino and tromino tiling
  • Find the sum of the power of all subsequences
  • Find xor beauty of array
  • Iterator for combination
  • Maximum number of groups with increasing length
  • Minimum number of operations to make string sorted
  • Naming a company
  • Number of good paths
  • Number of music playlists
  • Number of strings which can be rearranged to contain substring
  • Number of subsequences that satisfy the given sum condition
  • Number of ways to divide a long corridor
  • Number of ways to reach a position after exactly k steps
  • Number of ways to rearrange sticks with k sticks visible
  • Number of ways to reorder array to get same bst
  • Permutation sequence
  • Power of heroes
  • Probability of a two boxes having the same number of distinct balls
  • Right triangles
  • The number of beautiful subsets
  • Ways to split array into good subarrays

Inclusion-exclusion

  • Count increasing quadruplets
  • Distribute candies among children i
  • Distribute candies among children ii
  • Find all possible stable binary arrays i
  • Find all possible stable binary arrays ii
  • Find the sum of subsequence powers
  • Kth smallest amount with single denomination combination

Composition of operations

  • Bitwise xor of all pairings
  • Fancy sequence
  • Find xor sum of all pairs bitwise and
  • Handling sum queries after update

Expression rearrangement

  • Find maximum non decreasing array length
  • Maximum balanced subsequence sum
  • Number of pairs satisfying inequality

Geometry

  • Check if it is a straight line
  • Determine if a cell is reachable at a given time
  • Max points on a line
  • Maximum area of longest diagonal rectangle
  • Minimize manhattan distances
  • Minimum cuts to divide a circle
  • Rectangle area
  • Type of triangle ii

Convex hull

  • Erect the fence

Geometric median

  • Best position for a service centre
  • Minimum cost to make array equal

Invariants

  • Minimum operations to make array equal ii

Median

  • Apply operations to maximize frequency score
  • Minimum cost to make array equalindromic
  • Minimum operations to make median of array equal to k

Number theory

Basic

  • Add digits
  • Bulb switcher
  • Check if it is a good array
  • Check if point is reachable
  • Continuous subarray sum
  • Count beautiful substrings i
  • Count beautiful substrings ii
  • Count distinct numbers on board
  • Count of interesting subarrays
  • Count pairs of connectable servers in a weighted tree network
  • Destroy sequential targets
  • Excel sheet column title
  • Factorial trailing zeroes
  • Find the divisibility array of a string
  • Find the student that will replace the chalk
  • Greatest common divisor of strings
  • Integer break
  • Make k subarray sums equal
  • Maximum element sum of a complete subset of indices
  • Maximum number of k divisible components
  • Maximum prime difference
  • Minimize length of array using operations
  • Minimize the maximum of two arrays
  • Minimum cost to move chips to the same position
  • Minimum deletions to make array divisible
  • Minimum number of groups to create a valid assignment
  • Minimum number of operations to make all array elements equal to 1
  • Minimum rounds to complete all tasks
  • Mirror reflection
  • Most frequent prime
  • Nth magical number
  • Number of common factors
  • Number of subarrays with gcd equal to k
  • Number of subarrays with lcm equal to k
  • Prime in diagonal
  • Range product queries of powers
  • Smallest missing non negative integer after operations
  • Subarray sums divisible by k
  • Sum multiples
  • The number of beautiful subsets

Dynamic programming

  • Count the number of square free subsets
  • Largest divisible subset

Factor listing in sqrt(N)

  • Create components with same value
  • Largest divisible subset
  • Smallest value after replacing with sum of prime factors

Inclusion-exclusion

  • Kth smallest amount with single denomination combination

Modular exponentiation/inverse

  • Apply operations to maximize score
  • Count anagrams
  • Count collisions of monkeys on a polygon
  • Count good numbers
  • Count the number of ideal arrays
  • Count the number of infection sequences
  • Double modular exponentiation
  • Maximize number of nice divisors
  • Minimum number of operations to make string sorted
  • Number of subsequences that satisfy the given sum condition
  • String transformation

Prime sieving

  • Apply operations to maximize score
  • Closest prime numbers in range
  • Count primes
  • Count the number of ideal arrays
  • Count valid paths in a tree
  • Distinct prime factors of product of array
  • Greatest common divisor traversal
  • Largest component size by common factor
  • Maximum element sum of a complete subset of indices
  • Minimum changes to make k semi palindromes
  • Number of different subsequences gcds
  • Prime pairs with target sum
  • Prime subtraction operation
  • Split the array to make coprime products

Theorems

  • Perfect squares

Parity

  • Minimum reverse operations

Physics observation

  • Last moment before all ants fall out of a plank

Probability

  • Generate random point in a circle
  • Implement rand10 using rand7
  • Insert delete getrandom o1
  • Knight probability in chessboard
  • Linked list random node
  • New 21 game
  • Probability of a two boxes having the same number of distinct balls
  • Random pick with weight
  • Random point in non overlapping rectangles
  • Soup servings

Reduce problem dimension with proofs

  • Find a good subset of the matrix
  • Soup servings

Set theory

  • Find unique binary string
  • Maximum size of a set after removals

Matrix

  • Difference between ones and zeros in row and column
  • Difference of number of distinct values on diagonals
  • Find all groups of farmland
  • Find the grid of region average
  • Increment submatrices by one
  • Largest submatrix with rearrangements
  • Maximum strictly increasing cells in a matrix
  • Modify the matrix
  • Right triangles

Geometric transformation

  • Determine whether matrix can be obtained by rotation
  • Equal row and column pairs
  • Image overlap

Path

  • Disconnect path in a binary matrix by at most one flip
  • Dungeon game
  • Last day where you can still cross
  • Longest increasing path in a matrix
  • Maximum number of moves in a grid
  • Minimum falling path sum
  • Minimum falling path sum ii
  • Minimum path sum
  • Most frequent prime
  • Path with maximum gold
  • Paths in matrix whose sum is divisible by k
  • Where will the ball fall

Prefix

  • Construct product matrix

Row pair processing

  • Max sum of rectangle no larger than k
  • Number of submatrices that sum to target

Traversal

  • Count negative numbers in a sorted matrix
  • Diagonal traverse
  • Get biggest three rhombus sums in a grid

Meet in the middle

  • 4sum
  • 4sum ii
  • Matchsticks to square
  • Words within two edits of dictionary

Number transformations based on mathematical rules

  • Minimum addition to make integer beautiful
  • Minimum number of operations to make x and y equal
  • Minimum operations to reduce an integer to 0
  • Reach a number

Offline query processing

  • Checking existence of edge length limited paths
  • Find building where alice and bob can meet
  • Maximum sum queries
  • Minimum absolute difference queries

Palindrome

  • Break a palindrome
  • Count palindromic subsequences
  • Count paths that can form a palindrome in a tree
  • Find first palindromic string in the array
  • Largest palindromic number
  • Lexicographically smallest beautiful string
  • Lexicographically smallest palindrome
  • Longest palindrome
  • Longest palindrome by concatenating two letter words
  • Maximum number of non overlapping palindrome substrings
  • Maximum palindromes after operations
  • Minimum changes to make k semi palindromes
  • Minimum cost to make array equalindromic
  • Minimum insertion steps to make a string palindrome
  • Number of wonderful substrings
  • Palindrome linked list
  • Palindrome partitioning
  • Palindrome partitioning ii
  • Palindrome partitioning iii
  • Palindrome partitioning iv
  • Palindrome rearrangement queries
  • Palindromic substrings
  • Remove palindromic subsequences
  • Unique length 3 palindromic subsequences

Hashing

  • Longest palindromic substring
  • Palindrome pairs

Permutation

  • Permutation sequence

Cycle

  • Array nesting
  • Minimum number of operations to reinitialize a permutation
  • Minimum number of operations to sort a binary tree by level

Inverse

  • Build a matrix with conditions
  • Build array from permutation
  • Relative ranks

Inversions

  • Global and local inversions
  • Minimum adjacent swaps to reach the kth smallest number

Next/Previous

  • Minimum adjacent swaps to reach the kth smallest number
  • Minimum number of operations to make string sorted
  • Next greater element iii
  • Next permutation
  • Permutations ii

Swaps

  • Check if strings can be made equal with operations ii
  • Make lexicographically smallest array by swapping elements
  • Orderly queue
  • Semi ordered permutation

Pointers

  • Clone graph
  • Copy list with random pointer

Points in 2D plane

  • Find the number of ways to place people i
  • Find the number of ways to place people ii

Precomputation to answer queries efficiently with delta

  • Number of adjacent elements with the same color
  • Sum of even numbers after queries

Prefix

Bitwise operation

  • Maximum or
  • Number of wonderful substrings
  • Unique length 3 palindromic subsequences

Extremum

  • 132 pattern
  • Best sightseeing pair
  • Best time to buy and sell stock
  • Best time to buy and sell stock iii
  • Count subarrays with fixed bounds
  • Find the score of all prefixes of an array
  • Global and local inversions
  • Increasing triplet subsequence
  • Partition array into disjoint intervals
  • Using a robot to print the lexicographically smallest string

Sum

  • Apply operations to maximize frequency score
  • Binary subarrays with sum
  • Contiguous array
  • Continuous subarray sum
  • Count beautiful substrings i
  • Count beautiful substrings ii
  • Count complete substrings
  • Count days spent together
  • Count of interesting subarrays
  • Count subarrays where max element appears at least k times
  • Count subarrays with median k
  • Count subarrays with score less than k
  • Count tested devices after test operations
  • Count vowel strings in ranges
  • Delivering boxes from storage to ports
  • Execution of all suffix instructions staying in a grid
  • Find maximum non decreasing array length
  • Find the highest altitude
  • Find the score of all prefixes of an array
  • Find the substring with maximum cost
  • Gas station
  • Left and right sum differences
  • Longest subsequence with limited sum
  • Longest valid parentheses
  • Max sum of rectangle no larger than k
  • Maximal rectangle
  • Maximum good subarray sum
  • Maximum nesting depth of two valid parentheses strings
  • Maximum product subarray
  • Maximum score of spliced array
  • Maximum subarray
  • Maximum subarray min product
  • Maximum sum circular subarray
  • Maximum xor for each query
  • Minimum absolute difference queries
  • Minimum amount of time to collect garbage
  • Minimum cost to make all characters equal
  • Minimum edge weight equilibrium queries in a tree
  • Minimum moves to pick k ones
  • Minimum operations to make all array elements equal
  • Minimum size subarray in infinite array
  • Minimum space wasted from packaging
  • Minimum value to get positive step by step sum
  • Movement of robots
  • Palindrome rearrangement queries
  • Random pick with weight
  • Random point in non overlapping rectangles
  • Range sum query immutable
  • Reducing dishes
  • Remove zero sum consecutive nodes from linked list
  • Subarray sums divisible by k
  • Substring with largest variance
  • Sum of absolute differences in a sorted array

2D

  • Construct product matrix
  • Construct quad tree
  • Count submatrices with top left element and sum less than k
  • Disconnect path in a binary matrix by at most one flip
  • Increment submatrices by one
  • Maximal square
  • Number of submatrices that sum to target
  • Number of ways of cutting a pizza
  • Range sum query 2d immutable

For range updates

  • Apply operations to make all array elements equal to zero
  • Count the number of good partitions
  • Count the number of houses at a certain distance i
  • Count the number of houses at a certain distance ii
  • Increment submatrices by one
  • Invalid transactions
  • Maximize the minimum powered city

Valid brackets

  • Maximum nesting depth of the parentheses
  • Minimum remove to make valid parentheses
  • Remove invalid parentheses

Priority queue

  • Constrained subsequence sum
  • Earliest second to mark indices ii
  • Find original array from doubled array
  • First unique character in a string
  • Furthest building you can reach
  • Ipo
  • Jump game vi
  • Last stone weight
  • Length of the longest valid substring
  • Maximal score after applying k operations
  • Maximum frequency stack
  • Maximum number of events that can be attended
  • Maximum number of points from grid queries
  • Maximum spending after buying items
  • Meeting rooms iii
  • Merge k sorted lists
  • Minimize deviation in array
  • Minimum interval to include each query
  • Minimum operations to exceed threshold value ii
  • Minimum operations to form subsequence with target sum
  • Number of orders in the backlog
  • Parallel courses iii
  • Process tasks using servers
  • Remove stones to minimize the total
  • Reorganize string
  • Robot collisions
  • Sort an array
  • Time to cross a bridge
  • Total cost to hire k workers

Dijkstra's algorithm

  • Design graph with shortest path calculator
  • Minimum cost of a path with special roads
  • Minimum time to visit a cell in a grid
  • Modify graph edge weights
  • Network delay time

Dijkstra-like processing of subarrays

  • Find the k sum of an array

Dynamic sorted neighbour

  • Sum of imbalance numbers of all subarrays

K smallest/largest elements

  • Find k pairs with smallest sums
  • Find the most competitive subsequence
  • Get biggest three rhombus sums in a grid
  • Kth largest element in a stream
  • Lfu cache
  • Maximum elegance of a k length subsequence
  • Maximum performance of a team
  • Maximum subsequence score
  • Minimum cost to hire k workers

Transfer between the two

  • Divide an array into subarrays with minimum cost i
  • Divide an array into subarrays with minimum cost ii
  • Find median from data stream
  • Finding mk average

Key update using insert and remove on C++ set

  • Count zero request servers
  • Design a food rating system
  • Design a number container system
  • Design authentication manager
  • Design graph with shortest path calculator
  • Find edges in shortest paths
  • Lfu cache
  • Lru cache
  • Minimum cost of a path with special roads
  • Minimum time to visit a cell in a grid
  • Minimum time to visit disappearing nodes
  • Modify graph edge weights
  • Network delay time
  • Number of ways to arrive at destination
  • Path with maximum probability
  • Reachable nodes in subdivided graph
  • Take gifts from the richest pile

Process in unusual order

  • Reconstruct original digits from english

Process multiple vectors together

  • Number of matching subsequences

QuadTree

  • Construct quad tree

Queue

  • Number of recent calls

Quick Select

  • Kth largest element in an array
  • Minimum moves to equal array elements ii

Range updates using prefix sum

  • Invalid transactions

Search by iterative bound improvement

  • Minimize the maximum of two arrays

Segment tree

  • Count increasing quadruplets
  • Count of range sum
  • Count of smaller numbers after self
  • Count pairs with xor in a range
  • Create sorted array through instructions
  • Delivering boxes from storage to ports
  • Distribute elements into two arrays ii
  • Fancy sequence
  • Jump game vii
  • Longest increasing subsequence ii
  • Make array empty
  • Minimum sum of values by dividing array
  • Next greater element iv
  • Number of pairs satisfying inequality
  • Range sum query mutable

Lazy propagation

  • Handling sum queries after update
  • Subarrays distinct element sum of squares i
  • Subarrays distinct element sum of squares ii

Simple implementation

  • Account balance after rounded purchase
  • Add to array form of integer
  • Alternating digit sum
  • Ant on the boundary
  • Apply operations to an array
  • Arithmetic subarrays
  • Arranging coins
  • Average salary excluding the minimum and maximum salary
  • Average value of even numbers that are divisible by three
  • Beautiful towers i
  • Best poker hand
  • Bulls and cows
  • Calculate amount paid in taxes
  • Calculate delayed arrival time
  • Can place flowers
  • Categorize box according to criteria
  • Check distances between same letters
  • Check if a string contains all binary codes of size k
  • Check if a string is an acronym of words
  • Check if all the integers in a range are covered
  • Check if matrix is x matrix
  • Check if number is a sum of powers of three
  • Check if strings can be made equal with operations i
  • Check if the sentence is pangram
  • Check if two string arrays are equivalent
  • Check if word equals summation of two words
  • Check knight tour configuration
  • Convert the temperature
  • Count and say
  • Count asterisks
  • Count number of distinct integers after reverse operations
  • Count odd numbers in an interval range
  • Count pairs whose sum is less than target
  • Count symmetric integers
  • Count the digits that divide a number
  • Count the number of special characters i
  • Count the number of vowel strings in range
  • Delete columns to make sorted
  • Determine color of a chessboard square
  • Determine if string halves are alike
  • Determine the winner of a bowling game
  • Difference between element sum and digit sum of an array
  • Difference between ones and zeros in row and column
  • Distribute candies
  • Distribute candies to people
  • Distribute elements into two arrays i
  • Divisible and non divisible sums difference
  • Duplicate zeros
  • Excel sheet column number
  • Existence of a substring in a string and its reverse
  • Faulty keyboard
  • Find common elements between two arrays
  • Find first palindromic string in the array
  • Find nearest point that has the same x or y coordinate
  • Find numbers with even number of digits
  • Find subarrays with equal sum
  • Find the array concatenation value
  • Find the distance value between two arrays
  • Find the losers of the circular game
  • Find the maximum divisibility score
  • Find the peaks
  • Find the pivot integer
  • Find the sum of encrypted integers
  • Find the town judge
  • Find the width of columns of a grid
  • Find the winner of an array game
  • Find the winner of the circular game
  • Find winner on a tic tac toe game
  • Find words containing character
  • Fizz buzz
  • Flipping an image
  • Game of life
  • Get biggest three rhombus sums in a grid
  • Get maximum in generated array
  • Greatest english letter in upper and lower case
  • Harshad number
  • How many numbers are smaller than the current number
  • Image overlap
  • Image smoother
  • Incremental memory leak
  • Integer replacement
  • Island perimeter
  • K items with the maximum sum
  • Kids with the greatest number of candies
  • Largest 3 same digit number in string
  • Largest local values in a matrix
  • Largest magic square
  • Largest positive integer that exists with its negative
  • Largest time for given digits
  • Last visited integers
  • Latest time you can obtain after replacing characters
  • Longest strictly increasing or strictly decreasing subarray
  • Make three strings equal
  • Match substring after replacement
  • Matrix diagonal sum
  • Matrix similarity after cyclic shifts
  • Maximum 69 number
  • Maximum count of positive integer and negative integer
  • Maximum difference by remapping a digit
  • Maximum number of balloons
  • Maximum number of operations with the same score i
  • Maximum number of pairs in array
  • Maximum score after splitting a string
  • Maximum star sum of a graph
  • Maximum sum of an hourglass
  • Maximum value of a string in an array
  • Merge strings alternately
  • Merge triplets to form target triplet
  • Min max game
  • Minimum amount of time to fill cups
  • Minimum changes to make alternating binary string
  • Minimum distance to the target element
  • Minimum domino rotations for equal row
  • Minimum hours of training to win a competition
  • Minimum number game
  • Minimum number of swaps to make the binary string alternating
  • Minimum operations to exceed threshold value i
  • Minimum time visiting all points
  • Modify the matrix
  • Most frequent even element
  • Next greater element i
  • Non decreasing array
  • Number of arithmetic triplets
  • Number of beautiful pairs
  • Number of changing keys
  • Number of employees who met the target
  • Number of senior citizens
  • Number of steps to reduce a number to zero
  • Number of unequal triplets in array
  • Odd string difference
  • Palindrome number
  • Pancake sorting
  • Partitioning into minimum number of deci binary numbers
  • Pass the pillow
  • Perform string shifts
  • Points that intersect with cars
  • Power of three
  • Powerful integers
  • Push dominoes
  • Queries on number of points inside a circle
  • Range addition ii
  • Remove all occurrences of a substring
  • Remove one element to make the array strictly increasing
  • Remove palindromic subsequences
  • Remove trailing zeros from a string
  • Reverse prefix of word
  • Row with maximum ones
  • Score of a string
  • Separate the digits in an array
  • Shortest and lexicographically smallest beautiful string
  • Shortest distance to target string in a circular array
  • Shuffle the array
  • Smallest even multiple
  • Sort vowels in a string
  • Special positions in a binary matrix
  • Sum of number and its reverse
  • Sum of squares of special elements
  • The employee that worked on the longest task
  • Time needed to buy tickets
  • Toeplitz matrix
  • Total distance traveled
  • Ugly number
  • Water bottles ii
  • Zigzag conversion

Simple implementation0

  • Make a square with the same color

Sliding window

  • 3sum
  • 3sum closest
  • Apply operations to maximize frequency score
  • Binary trees with factors
  • Constrained subsequence sum
  • Contains duplicate ii
  • Continuous subarrays
  • Count pairs of nodes
  • Count the number of fair pairs
  • Count the number of good subarrays
  • Count the number of incremovable subarrays i
  • Count the number of incremovable subarrays ii
  • Divide an array into subarrays with minimum cost i
  • Divide an array into subarrays with minimum cost ii
  • Find a value of a mysterious function closest to target
  • Find all anagrams in a string
  • Find the longest equal subarray
  • Frequency of the most frequent element
  • Fruit into baskets
  • Invalid transactions
  • K radius subarray averages
  • K th smallest prime fraction
  • Length of longest subarray with at most k frequency
  • Longest duplicate substring
  • Longest harmonious subsequence
  • Longest subarray of 1s after deleting one element
  • Longest substring without repeating characters
  • Max consecutive ones iii
  • Maximize the confusion of an exam
  • Maximize win from two segments
  • Maximum beauty of an array after applying operation
  • Maximum erasure value
  • Maximum number of vowels in a substring of given length
  • Maximum points you can obtain from cards
  • Maximum strong pair xor i
  • Maximum strong pair xor ii
  • Maximum sum of almost unique subarray
  • Maximum sum of distinct subarrays with length k
  • Minimum moves to pick k ones
  • Minimum number of operations to make array continuous
  • Minimum operations to reduce x to zero
  • Minimum recolors to get k consecutive black blocks
  • Minimum rectangles to cover points
  • Minimum size subarray sum
  • Minimum window substring
  • Permutation in string
  • Sliding subarray beauty
  • Subarrays with k different integers
  • Subsequence with the minimum score

Monotonic deque

  • Maximum number of robots within budget

String hashing

  • Find beautiful indices in the given array i
  • Find beautiful indices in the given array ii
  • Implement strstr

Sorting

  • Can make arithmetic progression from sequence
  • Check if array is good
  • Check if the number is fascinating
  • Count the number of fair pairs
  • Delete greatest value in each row
  • Divide players into teams of equal skill
  • Find all people with secret
  • High access employees
  • Largest perimeter triangle
  • Largest submatrix with rearrangements
  • Longest square streak in an array
  • Majority element
  • Maximize area of square hole in grid
  • Maximum area of a piece of cake after horizontal and vertical cuts
  • Maximum gap
  • Maximum star sum of a graph
  • Minimum absolute difference
  • Minimum number of operations to make array continuous
  • Minimum number of operations to make arrays similar
  • Movement of robots
  • Number of distinct averages
  • Reduction operations to make the array elements equal
  • Sum in a matrix
  • The number of beautiful subsets
  • The number of weak characters in the game
  • Widest vertical area between two points containing no points

Custom

  • Advantage shuffle
  • Array of doubled pairs
  • Best team with no conflicts
  • Checking existence of edge length limited paths
  • Closest room
  • Concatenated words
  • Container with most water
  • Course schedule iii
  • Custom sort string
  • Design a food rating system
  • Diagonal traverse ii
  • Divide intervals into minimum number of groups
  • Earliest possible day of full bloom
  • Eliminate maximum number of monsters
  • Find the number of ways to place people i
  • Find the number of ways to place people ii
  • K closest points to origin
  • Largest number
  • Longest string chain
  • Maximize the profit as the salesman
  • Maximum length of pair chain
  • Maximum number of points from grid queries
  • Maximum profit in job scheduling
  • Maximum units on a truck
  • Merge k sorted lists
  • Minimum number of arrows to burst balloons
  • Minimum number of taps to open to water a garden
  • Minimum sum of squared difference
  • Next greater element iv
  • Non overlapping intervals
  • Reward top k students
  • Sort integers by the number of 1 bits
  • Sort the people
  • Sort the students by their kth score

Implementation

  • Sort an array

Index array

  • Apply operations to maximize score
  • Best team with no conflicts
  • Checking existence of edge length limited paths
  • Count zero request servers
  • Find score of an array after marking all elements
  • Ipo
  • Make array empty
  • Maximum elegance of a k length subsequence
  • Maximum subsequence score
  • Maximum sum queries
  • Minimum time to make array sum at most x
  • Robot collisions

Merge sort

  • Merge k sorted lists
  • Merge sorted array
  • Merge two sorted lists

Partial

  • Buy two chocolates
  • K closest points to origin
  • Kth largest sum in a binary tree
  • Make k subarray sums equal
  • Mice and cheese
  • Neither minimum nor maximum

Queries and updates together

  • Count zero request servers
  • Minimum space wasted from packaging
  • Number of flowers in full bloom
  • Number of good paths

Remembering index

  • Closest nodes queries in a binary search tree
  • Find right interval
  • Invalid transactions
  • Make lexicographically smallest array by swapping elements
  • Mark elements on array by performing queries
  • Relative ranks
  • Sum of subarray minimums

Stable

  • Difference between maximum and minimum price sum
  • Query kth smallest trimmed number

Stack

  • Binary search tree iterator
  • Build an array with stack operations
  • Min stack
  • Removing stars from a string

Depth first search

  • Binary tree inorder traversal
  • Find eventual safe states

From array elements

  • Asteroid collision
  • Longest valid parentheses
  • Make the string great
  • Minimum string length after removing substrings
  • Remove all adjacent duplicates in string ii
  • Using a robot to print the lexicographically smallest string

Monotonic stack

  • Apply operations to maximize score
  • Beautiful towers ii
  • Daily temperatures
  • Find building where alice and bob can meet
  • Find the number of subarrays where boundary elements are maximum
  • Largest rectangle in histogram
  • Maximum score of a good subarray
  • Maximum subarray min product
  • Maximum sum queries
  • Minimum difficulty of a job schedule
  • Next greater element ii
  • Online stock span

Numerical operations

  • Baseball game
  • Basic calculator
  • Basic calculator ii
  • Evaluate reverse polish notation
  • Minimum cost to change the final value of expression

String

Anagrams

  • Group anagrams

Parsing

  • Basic calculator
  • Basic calculator ii
  • Circular sentence
  • Compare version numbers
  • Complex number multiplication
  • Count anagrams
  • Count days spent together
  • Detect capital
  • Evaluate the bracket pairs of a string
  • Find duplicate file in system
  • Goat latin
  • Invalid transactions
  • Length of last word
  • Minimum cost to change the final value of expression
  • Number of different integers in a string
  • Reverse words in a string iii
  • Reward top k students
  • Split message based on limit
  • Split strings by separator
  • Utf 8 validation

Recursive

  • Decode string
  • Number of atoms

Search

  • Shortest uncommon substring in an array

Hashing

  • Concatenated words
  • Count prefix and suffix pairs i
  • Count prefix and suffix pairs ii
  • Find beautiful indices in the given array i
  • Find beautiful indices in the given array ii
  • Implement strstr
  • Longest duplicate substring
  • Maximum deletions on a string
  • Minimum time to revert word to initial state i
  • Minimum time to revert word to initial state ii
  • Number of subarrays that match a pattern i
  • Number of subarrays that match a pattern ii
  • Palindrome pairs
  • String transformation
  • Sum of prefix scores of strings

Prefix/Suffix

  • Prefix and suffix search
  • Shortest string that contains three strings

Trie

  • Length of the longest valid substring
  • Longest common suffix queries

Subsequence

  • Append characters to string to make subsequence
  • Is subsequence
  • Longest common subsequence
  • Longest uncommon subsequence ii
  • Longest word in dictionary through deleting
  • Make string a subsequence using cyclic increments
  • Maximum number of removable characters
  • Number of matching subsequences
  • Remove duplicate letters
  • Subsequence with the minimum score

Suffix array

  • Query kth smallest trimmed number

Validation

  • Ambiguous coordinates
  • Number of valid clock times

Time reversed simulation

  • Backspace string compare
  • Construct target array with multiple sums
  • Maximum segment sum after removals
  • Maximum spending after buying items
  • Sum of matrix after queries

Tree

Binary search tree

  • Insert into a binary search tree
  • Kth smallest element in a bst
  • Minimum absolute difference in bst
  • Minimum distance between bst nodes
  • Number of ways to reorder array to get same bst
  • Range sum of bst
  • Recover binary search tree

Traversal

  • All elements in two binary search trees
  • Binary search tree iterator
  • Construct binary search tree from preorder traversal
  • Convert bst to greater tree
  • Delete node in a bst
  • Increasing order search tree

Binary tree

  • Cycle length queries in a tree

Iteration

  • Binary tree inorder traversal
  • Make costs of paths equal in a binary tree
  • Maximum level sum of a binary tree
  • Populating next right pointers in each node ii

Recursion

  • Add one row to tree
  • All nodes distance k in binary tree
  • All possible full binary trees
  • Average of levels in binary tree
  • Balanced binary tree
  • Binary tree cameras
  • Binary tree level order traversal
  • Binary tree level order traversal ii
  • Binary tree maximum path sum
  • Binary tree preorder traversal
  • Binary tree pruning
  • Binary tree right side view
  • Binary tree tilt
  • Binary tree zigzag level order traversal
  • Check completeness of a binary tree
  • Check if a string is a valid sequence from root to leaves path in a binary tree
  • Construct binary search tree from preorder traversal
  • Construct binary tree from inorder and postorder traversal
  • Construct binary tree from preorder and inorder traversal
  • Construct string from binary tree
  • Convert bst to greater tree
  • Convert sorted array to binary search tree
  • Convert sorted list to binary search tree
  • Count good nodes in binary tree
  • Count nodes equal to average of subtree
  • Cousins in binary tree
  • Cousins in binary tree ii
  • Deepest leaves sum
  • Delete node in a bst
  • Delete nodes and return forest
  • Diameter of binary tree
  • Distribute coins in binary tree
  • Evaluate boolean binary tree
  • Even odd tree
  • Find a corresponding node of a binary tree in a clone of that tree
  • Find bottom left tree value
  • Find duplicate subtrees
  • Find largest value in each tree row
  • Find mode in binary search tree
  • Flatten binary tree to linked list
  • Flip binary tree to match preorder traversal
  • Height of binary tree after subtree removal queries
  • House robber iii
  • Increasing order search tree
  • Invert binary tree
  • Kth largest sum in a binary tree
  • Kth smallest element in a bst
  • Leaf similar trees
  • Longest univalue path
  • Longest zigzag path in a binary tree
  • Lowest common ancestor of a binary search tree
  • Lowest common ancestor of a binary tree
  • Maximum depth of binary tree
  • Maximum difference between node and ancestor
  • Maximum product of splitted binary tree
  • Maximum width of binary tree
  • Minimum absolute difference in bst
  • Minimum depth of binary tree
  • Minimum distance between bst nodes
  • Minimum number of operations to sort a binary tree by level
  • Number of ways to reorder array to get same bst
  • Path sum
  • Path sum ii
  • Path sum iii
  • Populating next right pointers in each node
  • Pseudo palindromic paths in a binary tree
  • Range sum of bst
  • Recover binary search tree
  • Smallest string starting from leaf
  • Symmetric tree
  • Validate binary tree nodes

Hashing

  • Find duplicate subtrees

Level-wise processing

  • Maximum level sum of a binary tree
  • Minimum number of operations to sort a binary tree by level

Order traversal

  • Binary tree preorder traversal
  • Construct binary tree from inorder and postorder traversal
  • Construct binary tree from preorder and inorder traversal
  • Flip binary tree to match preorder traversal
  • Height of binary tree after subtree removal queries
  • N ary tree level order traversal
  • N ary tree preorder traversal
  • Reverse odd levels of binary tree

Rerooting

  • Amount of time for binary tree to be infected

Trie

  • Design add and search words data structure
  • Implement trie prefix tree
  • Length of the longest valid substring
  • Longest common suffix queries
  • Maximum strong pair xor i
  • Maximum strong pair xor ii
  • Word search ii

Two player games

  • Predict the winner
  • Stone game iii

Two pointers

  • Assign cookies
  • Find all people with secret
  • Find indices with index and value difference i
  • Find indices with index and value difference ii
  • Find k closest elements
  • Find the longest semi repetitive substring
  • Make lexicographically smallest array by swapping elements
  • Maximize greatness of an array
  • Merge two 2d arrays by summing values
  • Minimum common value
  • Minimum length of string after deleting similar ends
  • Number of subsequences that satisfy the given sum condition
  • Rearrange array elements by sign
  • Reverse vowels of a string

Unique elements in subarray

  • Count unique characters of all substrings of a given string
  • Longest nice subarray
  • Longest substring without repeating characters
  • Maximum erasure value
  • Optimal partition of string

Unique/duplicate element finding with bizarro algorithms

  • Find all duplicates in an array
  • Find all numbers disappeared in an array
  • Find missing and repeated values
  • Find the difference
  • First missing positive
  • Missing number

Valid subarray counting

Iterate one endpoint and keep valid range for other

  • Count subarrays with fixed bounds

Untagged

  • Broken calculator
  • Buddy strings
  • Counting elements
  • Decoded string at index
  • Flip string to monotone increasing
  • Leftmost column with at least a one
  • Move pieces to obtain a string
  • Range module
  • Reordered power of 2
  • Repeated dna sequences
  • Repeated substring pattern
  • Replace all digits with characters
  • Replace elements in an array
  • Reshape the matrix
  • Reverse bits
  • Reverse linked list
  • Reverse linked list ii
  • Reverse nodes in k group
  • Reverse only letters
  • Reverse pairs
  • Reverse string
  • Reverse words in a string
  • Richest customer wealth
  • Robot bounded in circle
  • Roman to integer
  • Rotate array
  • Rotate image
  • Rotate list
  • Rotating the box
  • Rotting oranges
  • Running sum of 1d array
  • Russian doll envelopes
  • Same tree
  • Score of parentheses
  • Scramble string
  • Search a 2d matrix
  • Search a 2d matrix ii
  • Search in a binary search tree
  • Search in rotated sorted array
  • Search in rotated sorted array ii
  • Search insert position
  • Search suggestions system
  • Seat reservation manager
  • Second largest digit in a string
  • Selling pieces of wood
  • Sentence similarity iii
  • Sequential digits
  • Serialize and deserialize binary tree
  • Serialize and deserialize bst
  • Set matrix zeroes
  • Set mismatch
  • Shift 2d grid
  • Shifting letters
  • Shifting letters ii
  • Short encoding of words
  • Shortest distance to a character
  • Shortest impossible sequence of rolls
  • Shortest palindrome
  • Shortest path in a grid with obstacles elimination
  • Shortest path in binary matrix
  • Shortest path visiting all nodes
  • Shortest subarray with sum at least k
  • Shortest unsorted continuous subarray
  • Shuffle an array
  • Sign of the product of an array
  • Simplify path
  • Single element in a sorted array
  • Single number
  • Single number ii
  • Single number iii
  • Single threaded cpu
  • Sliding puzzle
  • Sliding window maximum
  • Sliding window median
  • Slowest key
  • Smallest integer divisible by k
  • Smallest number in infinite set
  • Smallest range covering elements from k lists
  • Smallest range ii
  • Smallest string with a given numeric value
  • Smallest string with swaps
  • Smallest subtree with all the deepest nodes
  • Snakes and ladders
  • Sort array by increasing frequency
  • Sort array by parity
  • Sort array by parity ii
  • Sort characters by frequency
  • Sort colors
  • Sort integers by the power value
  • Sort items by groups respecting dependencies
  • Sort list
  • Sort the matrix diagonally
  • Sorting the sentence
  • Spiral matrix
  • Spiral matrix ii
  • Spiral matrix iv
  • Split array into consecutive subsequences
  • Split linked list in parts
  • Splitting a string into descending consecutive values
  • Sqrtx
  • Squares of a sorted array
  • Stamping the sequence
  • Steps to make array non decreasing
  • Stone game
  • Stone game ii
  • Stone game iv
  • Stone game vii
  • Stone game viii
  • Stream of characters
  • String compression
  • String to integer atoi
  • Strong password checker ii
  • Subarray product less than k
  • Subarray sum equals k
  • Subarray with elements greater than varying threshold
  • Subsets
  • Subsets ii
  • Substring with concatenation of all words
  • Substrings of size three with distinct characters
  • Subtree of another tree
  • Successful pairs of spells and potions
  • Sum of all subset xor totals
  • Sum of beauty of all substrings
  • Sum of digits in base k
  • Sum of distances in tree
  • Sum of floored pairs
  • Sum of left leaves
  • Sum of numbers with units digit k
  • Sum of root to leaf binary numbers
  • Sum of square numbers
  • Sum root to leaf numbers
  • Summary ranges
  • Super palindromes
  • Super washing machines
  • Surrounded regions
  • Swap nodes in pairs
  • Swapping nodes in a linked list
  • Swim in rising water
  • Target sum
  • Task scheduler
  • Task scheduler ii
  • Teemo attacking
  • Tenth line
  • Text justification
  • The dining philosophers
  • The earliest and latest rounds where players compete
  • The k weakest rows in a matrix
  • The kth factor of n
  • The latest time to catch a bus
  • The number of full rounds you have played
  • The skyline problem
  • Three equal parts
  • Time based key value store
  • Time needed to rearrange a binary string
  • To lower case
  • Top k frequent elements
  • Top k frequent words
  • Total appeal of a string
  • Transform to chessboard
  • Transpose matrix
  • Trapping rain water
  • Trapping rain water ii
  • Triangle
  • Trim a binary search tree
  • Triples with bitwise and equal to zero
  • Truncate sentence
  • Two city scheduling
  • Two sum
  • Two sum ii input array is sorted
  • Two sum iv input is a bst
  • Ugly number ii
  • Uncrossed lines
  • Unique binary search trees
  • Unique binary search trees ii
  • Unique email addresses
  • Unique morse code words
  • Unique paths
  • Unique paths ii
  • Unique paths iii
  • Valid anagram
  • Valid mountain array
  • Valid number
  • Valid palindrome
  • Valid palindrome ii
  • Valid parentheses
  • Valid parenthesis string
  • Valid perfect square
  • Valid square
  • Valid sudoku
  • Valid triangle number
  • Validate binary search tree
  • Validate ip address
  • Validate stack sequences
  • Verify preorder serialization of a binary tree
  • Verifying an alien dictionary
  • Vertical order traversal of a binary tree
  • Vowel spellchecker
  • Wiggle subsequence
  • Wildcard matching
  • Word break
  • Word break ii
  • Word ladder
  • Word ladder ii
  • Word pattern
  • Word search
  • Word subsets

Fraud

  • Add strings
  • Count complete tree nodes
  • Find minimum in rotated sorted array
  • Find minimum in rotated sorted array ii
  • Find peak element
  • Multiply strings
  • Next permutation

Suboptimal solution

  • Apply operations to make sum of array greater than or equal to k
  • Check if all the integers in a range are covered
  • Check if two string arrays are equivalent
  • Counting bits
  • Element appearing more than 25 in sorted array
  • Extra characters in a string
  • Find all numbers disappeared in an array
  • Find the duplicate number
  • Flatten nested list iterator
  • How many numbers are smaller than the current number
  • Kth missing positive number
  • Longest increasing subsequence
  • Longest strictly increasing or strictly decreasing subarray
  • Longest substring with at least k repeating characters
  • Longest word in dictionary
  • Map sum pairs
  • Maximum distance between a pair of values
  • Maximum length substring with two occurrences
  • Maximum score after splitting a string
  • Next greater element i
  • Split message based on limit