Tag LLVM

Write an LLVM Pass

In this post, I will show how I write an...


Tag Hash Table

X Of A Kind In A Deck Of Cards Problem

LeetCode 914. In a deck of cards, each card has...

Word Subsets Problem

LeetCode 916. You are given two string arrays words1 and...

Vowel Spellchecker Problem

LeetCode 966. Given a wordlist, we want to implement a...

Vertical Order Traversal Of A Binary Tree Problem

LeetCode 987. Given the root of a binary tree, calculate...

Verifying An Alien Dictionary Problem

LeetCode 953. In an alien language, surprisingly, they also use...

Unique Morse Code Words Problem

LeetCode 804. International Morse Code defines a standard encoding where...

Unique Email Addresses Problem

LeetCode 929. Every valid email consists of a local name...

Uncommon Words From Two Sentences Problem

LeetCode 884. A sentence is a string of single-space separated...

Triples With Bitwise And Equal To Zero Problem

LeetCode 982. Given an integer array nums, return the number...

Time Based Key-Value Store Problem

LeetCode 981. Design a time-based key-value data structure that can...

Subdomain Visit Count Problem

LeetCode 811. A website domain “discuss.leetcode.com” consists of various subdomains....

Subarrays With K Different Integers Problem

LeetCode 992. Given an integer array nums and an integer...

Smallest Subtree With All The Deepest Nodes Problem

LeetCode 865. Given the root of a binary tree, the...

Short Encoding Of Words Problem

LeetCode 820. A valid encoding of an array of words...

Prison Cells After N Days Problem

LeetCode 957. There are 8 prison cells in a row...

Powerful Integers Problem

LeetCode 970. Given three integers x, y, and bound, return...

Online Election Problem

LeetCode 911. You are given two integer arrays persons and...

Most Common Word Problem

LeetCode 819. Given a string paragraph and a string array...

Minimum Area Rectangle Problem

LeetCode 939. You are given an array of points in...

Maximum Frequency Stack Problem

LeetCode 895. Design a stack-like data structure to push elements...

Linked List Components Problem

LeetCode 817. You are given the head of a linked...

Length Of Longest Fibonacci Subsequence Problem

LeetCode 873. Given a strictly increasing array arr of positive...

Hand Of Straights Problem

LeetCode 846. Alice has some number of cards and she...

Groups Of Special-Equivalent Strings Problem

LeetCode 893. You are given an array of strings of...

Fruit Into Baskets Problem

LeetCode 904. You are visiting a farm that has a...

Find The Town Judge Problem

LeetCode 997. In a town, there are n people labeled...

Find And Replace Pattern Problem

LeetCode 890. Given a list of strings words and a...

Fair Candy Swap Problem

LeetCode 888. Alice and Bob have a different total number...

Count Unique Characters Of All Substrings Of A Given String Problem

LeetCode 828. Let’s define a function countUniqueChars(s) that returns the...

Construct Binary Tree From Preorder And Postorder Traversal Problem

LeetCode 889. Given two integer arrays, preorder and postorder where...

Card Flipping Game Problem

LeetCode 822. You are given n cards, with a positive...

Bus Routes Problem

LeetCode 815. You are given an array routes representing bus...

Buddy Strings Problem

LeetCode 859. Given two strings s and goal, return true...

Binary Trees With Factors Problem

LeetCode 823. Given an array of unique integers, arr, where...

Binary Subarrays With Sum Problem

LeetCode 930. Given a binary array nums and an integer...

Array Of Doubled Pairs Problem

LeetCode 954. Given an integer array of even length arr,...

3Sum With Multiplicity Problem

LeetCode 923. Given an integer array arr, and an integer...

Top K Frequent Words Problem

LeetCode 692. Given an array of strings words and an...

Task Scheduler Problem

LeetCode 621. Given a characters array tasks, representing the tasks...

Set Mismatch Problem

LeetCode 645. You have a set of integers s, which...

Reorganize String Problem

LeetCode 767. Given a string s, rearrange the characters of...

Random Pick With Blacklist Problem

LeetCode 710. You are given an integer n and an...

Rabbits In Forest Problem

LeetCode 781. There is a forest with an unknown number...

Partition Labels Problem

LeetCode 763. You are given a string s. We want...

Parse Lisp Expression Problem

LeetCode 736. You are given a string expression representing a...

Open The Lock Problem

LeetCode 752. You have a lock in front of you...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Split Array Into Consecutive Subsequences Problem

LeetCode 659. You are given an integer array nums that...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Shortest Completing Word Problem

LeetCode 748. Given a string licensePlate and an array of...

Prefix And Suffix Search Problem

LeetCode 745. Design a special dictionary with some words that...

Number Of Matching Subsequences Problem

LeetCode 792. Given a string s and an array of...

Number Of Atoms Problem

LeetCode 726. Given a string formula representing a chemical formula,return...

Find Duplicate File In System Problem

LeetCode 609. Given a list paths of directory info, including...

Map Sum Pairs Problem

LeetCode 677. Design a map that allows you to do...

Implement Magic Dictionary Problem

LeetCode 676. Design a data structure that is initialized with...

Find Duplicate Subtrees Problem

LeetCode 652. Given the rootof a binary tree, return all...

Employee Importance Problem

LeetCode 690. You have a data structure of employee information,...

Design Hashset Problem

LeetCode 705. Design a HashSet without using any built-in hash...

Design Hashmap Problem

LeetCode 706. Design a HashMap without using any built-in hash...

Delete And Earn Problem

LeetCode 740. You are given an integer array nums. You...

Degree Of An Array Problem

LeetCode 697. Given a non-empty array of non-negative integers nums,...

Custom Sort String Problem

LeetCode 791. You are given two strings order and s....

Basic Calculator IV Problem

LeetCode 770. Given an expression such as expression = “e...

Sort Characters By Frequency Problem

LeetCode 451. Given a string s, sort it in decreasing...

Sliding Window Median Problem

LeetCode 480. The median is the middle value in an...

Reconstruct Original Digits From English Problem

LeetCode 423. Given a string s containing an out-of-order English...

Random Flip Matrix Problem

LeetCode 519. There is an m x n binary grid...

Permutation In String Problem

LeetCode 567. Given two strings s1 and s2, return true...

Number Of Boomerangs Problem

LeetCode 447. You are given n points in the plane...

Next Greater Element I Problem

LeetCode 496. The next greater element of some element x...

Most Frequent Subtree Sum Problem

LeetCode 508. Given the root of a binary tree, return...

Minimum Genetic Mutation Problem

LeetCode 433. A gene string can be represented by an...

Minimum Index Sum Of Two Lists Problem

LeetCode 599. Suppose Andy and Doris want to choose a...

Longest Uncommon Subsequence II Problem

LeetCode 522. Given an array of strings strs, return the...

Longest Palindrome Problem

LeetCode 409. Given a string s which consists of lowercase...

Longest Harmonious Subsequence Problem

LeetCode 594. We define a harmonious array as an array...

LFU Cache Problem

LeetCode 460. Design and implement a data structure for a...

Keyboard Row Problem

LeetCode 500. Given an array of strings words, return the...

K-Diff Pairs In An Array Problem

LeetCode 532. Given an array of integers nums and an...

Increasing Subsequences Problem

LeetCode 491. Given an integer array nums, return all the...

Find Right Interval Problem

LeetCode 436. You are given an array of intervals, where...

Find All Numbers Disappeared In An Array Problem

LeetCode 448. Given an array nums of n integers where...

Find All Duplicates In An Array Problem

LeetCode 442. Given an integer array nums of length n...

Find All Anagrams In A String Problem

LeetCode 438. Given two strings s and p, return an...

Encode And Decode TinyURL Problem

LeetCode 535. TinyURL is a URL shortening service where you...

Distribute Candies Problem

LeetCode 575. Alice has n candies, where the i^th candy...

Contiguous Array Problem

LeetCode 525. Given a binary array nums, return the maximum...

Circular Array Loop Problem

LeetCode 457. You are playing a game involving a circular...

Brick Wall Problem

LeetCode 554. There is a rectangular brick wall in front...

All O'One Data Structure Problem

LeetCode 432. Design a data structure to store the strings...

Valid Anagram Problem

LeetCode 242. Given two strings s and t, return true...

Ugly Number II Problem

LeetCode 264. An ugly number is a positive integer whose...

Top K Frequent Elements Problem

LeetCode 347. Given an integer array nums and an integer...

Word Pattern Problem

LeetCode 290. Given a pattern and a string s, find...

Ransom Note Problem

LeetCode 383. Given two stings ransomNote and magazine, return true...

Random Pick Index Problem

LeetCode 398. Given an integer array nums with possible duplicates,...

Palindrome Pairs Problem

LeetCode 336. Given a list of unique words, return all...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Majority Element II Problem

LeetCode 229. Given an integer array of size n, find...

Isomorphic Strings Problem

LeetCode 205. Given two strings s and t, determine if...

Intersection Of Two Arrays II Problem

LeetCode 350. Given two integer arrays nums1 and nums2, return...

Insert Delete Getrandom O(1) - Duplicates Allowed Problem

LeetCode 381. RandomizedCollection is a data structure that contains a...

Happy Number Problem

LeetCode 202. Write an algorithm to determine if a number...

First Unique Character In A String Problem

LeetCode 387. Given a string s, find the first non-repeating...

Find The Difference Problem

LeetCode 389. You are given two strings s and t....

Design Twitter Problem

LeetCode 355. Design a simplified version of Twitter where users...

Contains Duplicate Problem

LeetCode 217. Given an integer array nums, return true if...

Contains Duplicate II Problem

LeetCode 219. Given an integer array nums and an integer...

Bulls And Cows Problem

LeetCode 299. You are playing the Bulls and Cows game...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...

Majority Element Problem

LeetCode 169. Given an array nums of size n, return...

Intersection Of Two Linked Lists Problem

LeetCode 160. Given the heads of two singly linked-lists headA...

Fraction To Recurring Decimal Problem

LeetCode 166. Given two integers representing the numerator and denominator...

Word Break Problem

LeetCode 139. Given a string s and a dictionary of...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Max Points On A Line Problem

LeetCode 149. Given an array of points where points[i] =...

Lru Cache Problem

LeetCode 146. Design a data structure that follows the constraints...

Linked List Cycle Problem

LeetCode 141. Given head, the head of a linked list,...

Linked List Cycle II Problem

LeetCode 142. Given the head of a linked list, return...

Copy List With Random Pointer Problem

LeetCode 138. A linked list of length n is given...

Clone Graph Problem

LeetCode 133. Given a reference of a node in a...

Word Ladder Problem

LeetCode 127. Given two words, beginWord and endWord, and a...

Word Ladder II Problem

LeetCode 126. Given two words, beginWord and endWord, and a...

Longest Consecutive Sequence Problem

LeetCode 128. Given an unsorted array of integers nums, return...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Set Matrix Zeroes Problem

LeetCode 73. Given an m x n integer matrix matrix,...

Search in Rotated Sorted Array Problem

LeetCode 36. Determine if a 9 x 9 Sudoku board...

Integer to Roman Problem

LeetCode 12. Given an integer, convert it to a roman...

Group Anagrams Problem

LeetCode 49. Given an array of strings strs, group the...

First Missing Positive Problem

LeetCode 41. Given an unsorted integer array nums, return the...

Roman to Integer Problem

LeetCode 13. Given a roman numeral, convert it to an...

Letter Combinations of a Phone Number Problem

LeetCode 17. Given a string containing digits from 2-9 inclusive,...

Sum Of Unique Elements Problem

LeetCode 1748. You are given an integer array nums. The...

Insert Delete GetRandom O(1) Problem

LeetCode 380. Implement a RandomizedSet class.

N-Repeated Element In Size 2N Array Problem

LeetCode 961. In a array A of size 2N, there...

Intersection Of Two Arrays Problem

LeetCode 349. Given two arrays, write a function to compute...

Intersection Of Three Sorted Arrays Problem

LeetCode 1213. Given three integer arrays arr1, arr2 and arr3...

Jewels And Stones Problem

LeetCode 771. You’re given strings jewels representing the types of...

Number Of Good Pairs Problem

LeetCode 1512. Given an array of integers nums. Return the...

Kth Missing Positive Number Problem

LeetCode 1539. Given an array arr of positive integers sorted...

Maximum Equal Frequency Problem

LeetCode 1224. Given an array nums of positive integers, return...

Subarray Sum Divisible By K Problem

LeetCode 974. Given an array of integers nums and an...

Four Sum II Problem

LeetCode 454. Given four lists A, B, C, D of...

Continuous Subarray Sum Problem

LeetCode 523. Given an array of non-negative integers nums and...

Subarray Sum Equals K Problem

LeetCode 560. Given an array of integers nums and an...

Two Sum Problem

LeetCode 1. Given an array of integers nums and an...

Tag Leetcode

Symmetric Tree Problem

LeetCode 101. Given the root of a binary tree, check...

Maximum Depth of Binary Tree Problem

LeetCode 104. Given the root of a binary tree, return...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Construct Binary Tree From Inorder And Postorder Traversal Problem

LeetCode 106. Given two integer arrays inorder and postorder where...

Binary Tree Zigzag Level Order Traversal Problem

LeetCode 103. Given the root of a binary tree, return...

Binary Tree Level Order Traversal Problem

LeetCode 102. Given the root of a binary tree, return...

Binary Tree Level Order Traversal II Problem

LeetCode 107. Given the root of a binary tree, return...

Validate Binary Search Tree Problem

LeetCode 98. Given the root of a binary tree, determine...

Same Tree Problem

LeetCode 100. Given the roots of two binary trees p...

Recover Binary Search Tree Problem

LeetCode 99. You are given the root of a binary...

Interleaving String Problem

LeetCode 97. Given strings s1, s2, and s3, find whether...

Word Search Problem

LeetCode 79. Given an m x n grid of characters...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Subsets Problem

LeetCode 78. Given an integer array nums of unique elements,...

Subsets II Problem

LeetCode 90. Given an integer array nums that may contain...

Search in Rotated Sorted Array II Problem

LeetCode 81. There is an integer array nums sorted in...

Scramble String Problem

LeetCode 87. Given two strings s1 and s2 of the...

Restore IP Addresses Problem

LeetCode 93. Given a string s containing only digits, return...

Remove Duplicates from Sorted List Problem

LeetCode 83. Given the head of a sorted linked list,...

Remove Duplicates from Sorted List II Problem

LeetCode 82. Given the head of a sorted linked list,...

Remove Duplicates from Sorted Array II Problem

LeetCode 80. Given an integer array nums sorted in non-decreasing...

Partition List Problem

LeetCode 86. Given the head of a linked list and...

Merge Sorted Array Problem

LeetCode 88. You are given two integer arrays nums1 and...

Maximal Rectangle Problem

LeetCode 85. Given a rows x cols binary matrix filled...

Largest Rectangle in Histogram Problem

LeetCode 84. Given an array of integers heights representing the...

Gray Code Problem

LeetCode 89. Given an integer n, return any valid n-bit...

Decode Ways Problem

LeetCode 91. Given a string s containing only digits, return...

Binary Tree Inorder Traversal Problem

LeetCode 94. Given an m x n grid of characters...

Sort Colors Problem

LeetCode 75. Given an array nums with n objects colored...

Simplify Path Problem

LeetCode 71. Given a string path, which is an absolute...

Set Matrix Zeroes Problem

LeetCode 73. Given an m x n integer matrix matrix,...

Search A 2D Matrix Problem

LeetCode 74. Write an efficient algorithm that searches for a...

Minimum Window Substring Problem

LeetCode 76. Given two strings s and t of lengths...

Edit Distance Problem

LeetCode 72. Given two strings word1 and word2, return the...

Combinations Problem

LeetCode 77. Given two integers n and k, return all...

Valid Number Problem

LeetCode 65. Given a string s, return true if s...

Unique Paths Problem

LeetCode 62. A robot is located at the top-left corner...

Unique Paths II Problem

LeetCode 63. A robot is located at the top-left corner...

Text Justification Problem

LeetCode 68. Given an array of strings words and a...

Rotate List Problem

LeetCode 61. Given the head of a linked list, rotate...

Plus One Problem

LeetCode 66. You are given a large integer represented as...

Minimum Path Sum Problem

LeetCode 64. Given a m x n grid filled with...

Climbing Stairs Problem

LeetCode 70. You are climbing a staircase. It takes n...

Valid Number Problem

LeetCode 67. A robot is located at the top-left corner...

Spiral Matrix Problem

LeetCode 54. Given an m x n matrix, return all...

Spiral Matrix II Problem

LeetCode 59. Given a positive integer n, generate an n...

Permutation Sequence Problem

LeetCode 60. Given n and k, return the kth permutation...

N-Queens Problem

LeetCode 51. Given an integer n, return all distinct solutions...

N-Queens II Problem

LeetCode 52. Given an integer n, return the number of...

Maximum Subarray Problem

LeetCode 53. Given an integer array nums, find the contiguous...

Length Of Last Word Problem

LeetCode 58. Given a string s consisting of some words...

Jump Game Problem

LeetCode 55. Given an m x n matrix, return all...

Insert Interval Problem

LeetCode 57. Insert newInterval into intervals such that intervals is...

Zigzag Conversion Problem

LeetCode 6. Write the code that will take a string...

Wildcard Matching Problem

LeetCode 44. Write the code that will take a string...

Search in Rotated Sorted Array Problem

LeetCode 36. Determine if a 9 x 9 Sudoku board...

Trapping Rain Water Problem

LeetCode 42. Given n non-negative integers representing an elevation map...

Sudoku Solver Problem

LeetCode 37. Write a program to solve a Sudoku puzzle...

Search in Rotated Sorted Array Problem

LeetCode 33. Given the array nums after the possible rotation...

Rotate Image Problem

LeetCode 48. Determine if a 9 x 9 Sudoku board...

Reverse Nodes in k-Group Problem

LeetCode 25. Given a linked list, reverse the nodes of...

Remove Element Problem

LeetCode 27. Given an integer array nums and an integer...

Regular Expression Matching Problem

LeetCode 10. Given an input string s and a pattern...

Pow(x,n) Problem

LeetCode 50. Determine if a 9 x 9 Sudoku board...

Permutations Problem

LeetCode 46. Given an array nums of distinct integers, return...

Permutations II Problem

LeetCode 47. Given a collection of numbers, nums, that might...

Palindrome Number Problem

LeetCode 9. Given an integer x, return true if x...

Next Permutation Problem

LeetCode 31. Implement next permutation, which rearranges numbers into the...

Multiply Strings Problem

LeetCode 43. Given two non-negative integers num1 and num2 represented...

Jump Game II Problem

LeetCode 45. Given an array of non-negative integers nums, you...

Integer to Roman Problem

LeetCode 12. Given an integer, convert it to a roman...

Group Anagrams Problem

LeetCode 49. Given an array of strings strs, group the...

First Missing Positive Problem

LeetCode 41. Given an unsorted integer array nums, return the...

Find First and Last Position of Element in Sorted Array Problem

LeetCode 34. Given the array nums after the possible rotation...

Divide Two Integers Problem

LeetCode 29. Write the code that will take a string...

Count and Say Problem

LeetCode 38. Write the code that will take a string...

Combination Sum Problem

LeetCode 39. Given an array of distinct integers candidates and...

Combination Sum II Problem

LeetCode 40. Given a collection of candidate numbers (candidates) and...

3Sum Closest Problem

LeetCode 16. Given an integer array nums of length n...

Valid Parentheses Problem

LeetCode 20. Given a string s containing just the characters...

Swap Nodes in Pairs Problem

LeetCode 24. Given a linked list, swap every two adjacent...

Roman to Integer Problem

LeetCode 13. Given a roman numeral, convert it to an...

Reverse Integer Problem

LeetCode 7. Given a signed 32-bit integer x, return x...

Remove Nth Node From End of List Problem

LeetCode 19. Given the head of a linked list, remove...

Remove Duplicates from Sorted Array Problem

LeetCode 26. Given an integer array nums sorted in non-decreasing...

Longest Palindromic Substring Problem

LeetCode 5. Given a string s, return the longest palindromic...

Longest Common Prefix Problem

LeetCode 14. Write a function to find the longest common...

Letter Combinations of a Phone Number Problem

LeetCode 17. Given a string containing digits from 2-9 inclusive,...

Generate Parentheses Problem

LeetCode 22. Given n pairs of parentheses, write a function...

Depth of BST Given Insertion Order Problem

LeetCode 1902. You are given a 0-indexed integer array order...

Container With Most Water Problem

LeetCode 11. Given n non-negative integers a_1, a_2, …, a_n...

Smallest Greater Multiple Made of Two Digits Problem

LeetCode 1999. Given three integers, k, digit1, and digit2, you...

Reverse Prefix of Word Problem

LeetCode 2000. Given a 0-indexed string word and a character...

Users That Actively Request Confirmation Messages Problem

LeetCode 1939. Write an SQL query to find the IDs...

Strong Friendship Problem

LeetCode 1949. Write an SQL query to find all the...

Leetcodify Similar Friends Problem

LeetCode 1919. Write an SQL query to report the similar...

Leetcodify Friends Recommendations Problem

LeetCode 1917. Write an SQL query to recommend friends to...

First and Last Call On the Same Day Problem

LeetCode 1972. Write an SQL query to report the IDs...

Find Cutoff Score for Each School Problem

LeetCode 1988. Write an SQL query to report the minimum...

Employees With Missing Information Problem

LeetCode 1965. Write an SQL query to report the IDs...

Employees Whose Manager Left the Company Problem

LeetCode 1978. Write an SQL query to report the IDs...

Count the Number of Experiments Problem

LeetCode 1990. Write an SQL query to report the number...

Count Salary Categories Problem

LeetCode 1907. Write an SQL query to report the number...

Confirmation Rate Problem

LeetCode 1934. Write an SQL query to find the confirmation...

All the Pairs With the Maximum Number of Common Followers Problem

LeetCode 1951. Write an SQL query to find all the...

The Latest Login in 2020 Problem

LeetCode 1890. Write an SQL query to report the latest...

Suspicious Bank Accounts Problem

LeetCode 1843. Write an SQL query to report the IDs...

Page Recommendations II Problem

LeetCode 1892. Write an SQL query to find all the...

Orders With Maximum Quantity Above Average Problem

LeetCode 1867. Write an SQL query to find the order_id...

Maximum Transaction Each Day Problem

LeetCode 1831. Write an SQL query to report the IDs...

League Statistics Problem

LeetCode 1841. Write an SQL query to report the statistics...

Group Employees of the Same Salary Problem

LeetCode 1875. Write an SQL query to report the IDs...

Find Customers With Positive Revenue this Year Problem

LeetCode 1821. Write an SQL query to report the customers...

Convert Date Format Problem

LeetCode 1853. Write an SQL query to convert each date...

Calculate Special Bonus Problem

LeetCode 1873. Write an SQL query to calculate the bonus...

Rearrange Products Table Problem

LeetCode 1795. Write an SQL query to rearrange the Products...

Find Interview Candidates Problem

LeetCode 1811. Write an SQL query to report the name...

Determine Color Of A Chessboard Square Problem

LeetCode 1812. You are given coordinates, a string that represents...

Ad-Free Sessions Problem

LeetCode 1809. Write an SQL query to report all the...

String To Interger (atoi) Problem

LeetCode 8. Implement the myAtoi(string s) function, which converts a...

Primary Department For Each Employee Problem

LeetCode 1789. Write an SQL query to report all the...

Grand Slam Titles Problem

LeetCode 1783. Write an SQL query to report the number...

Product's Price For Each Store Problem

LeetCode 1777. Write an SQL query to find the price...

Find The Subtasks That Did Not Execute Problem

LeetCode 1767. Write an SQL query to report the IDs...

Add Two Numbers Problem

LeetCode 2. You are given two non-empty linked lists representing...

Sum Of Unique Elements Problem

LeetCode 1748. You are given an integer array nums. The...

Recyclable And Low Fat Products Problem

LeetCode 1757. Write an SQL query to find the ids...

Leetflex Banned Accounts Problem

LeetCode 1747. Write an SQL query to find the account_id...

Insert Delete GetRandom O(1) Problem

LeetCode 380. Implement a RandomizedSet class.

N-Repeated Element In Size 2N Array Problem

LeetCode 961. In a array A of size 2N, there...

Intersection Of Two Arrays Problem

LeetCode 349. Given two arrays, write a function to compute...

Intersection Of Three Sorted Arrays Problem

LeetCode 1213. Given three integer arrays arr1, arr2 and arr3...

Find Total Time Spent By Each Employee Problem

LeetCode 1741. Write an SQL query to calculate the total...

Jewels And Stones Problem

LeetCode 771. You’re given strings jewels representing the types of...

Number Of Good Pairs Problem

LeetCode 1512. Given an array of integers nums. Return the...

Kth Missing Positive Number Problem

LeetCode 1539. Given an array arr of positive integers sorted...

The Number Of Employees Which Report To Each Employee Problem

LeetCode 1731. Write an SQL query to report the ids...

Find Followers Count Problem

LeetCode 1729. Write an SQL query that will, for each...

Count Apples And Oranges Problem

LeetCode 1715. Write an SQL query to count the number...

Biggest Window Between Visits Problem

LeetCode 1709. Write an SQL query that will, for each...

Total Sales Amount By Year Problem

LeetCode 1384. Write an SQL query to report the Total...

Sales By Day Of The Week Problem

LeetCode 1479. Write an SQL query to report how many...

Hopper Company Queries III Problem

LeetCode 1651. Write an SQL query to compute the average_ride_distance...

Get The Second Most Recent Activity Problem

LeetCode 1369. Write an SQL query to show the second...

Find The Quiet Students In All Exams Problem

LeetCode 1412. Write an SQL query to report the students...

Tournament Winners Problem

LeetCode 1194. Write an SQL query to find the winner...

Students Report By Geography Problem

LeetCode 618. A U.S graduate school has students from Asia,...

Report Contiguous Dates Problem

LeetCode 1225. Write an SQL query to generate a report...

Median Employee Salary Problem

LeetCode 569. Write a SQL query to find the median...

Market Analysis II Problem

LeetCode 1159. Write an SQL query to find for each...

Hopper Company Queries I Problem

LeetCode 1635. Write an SQL query to report the following...

Game Play Analysis V Problem

LeetCode 1097. Write an SQL query that reports for each...

User Purchase Platform Problem

LeetCode 1127. Write an SQL query to find the total...

Trips And Users Problem

LeetCode 262. Write a SQL query to find the cancellation...

Number Of Transactions Per Visit Problem

LeetCode 1336. Write an SQL query to find how many...

Human Traffic Of Stadium Problem

LeetCode 601. Write an SQL query to display the records...

Hopper Company Queries II Problem

LeetCode 1645. Write an SQL query to report the percentage...

Find Median Given Frequency Of Numbers Problem

LeetCode 571. Write a query to find the median of...

Find Cumulative Salary Of An Employee Problem

LeetCode 579. Write a SQL to get the cumulative sum...

Department Top Three Salaries Problem

LeetCode 185. Write a SQL query to find employees who...

Average Salary: Departments VS Company Problem

LeetCode 615. Given two tables as below, write a query...

Unpopular Books Problem

LeetCode 1098. Write an SQL query that reports the books...

Second Degree Follower Problem

LeetCode 614. Please write a sql query to get the...

Reported Posts II Problem

LeetCode 1132. Write an SQL query to find the average...

Number Of Calls Between Two Persons Problem

LeetCode 1699. Write an SQL query to report the number...

Nth Highest Salary Problem

LeetCode 177. Write a SQL query to get the nth...

New Users Daily Count Problem

LeetCode 1107. Write an SQL query that reports for every...

Monthly Transactions II Problem

LeetCode 1205. Write an SQL query to find for each...

Get Highest Answer Rate Question Problem

LeetCode 578. Write a sql query to identify the question...

Department Highest Salary Problem

LeetCode 184. Write a SQL query to find employees who...

Article Views II Problem

LeetCode 1149. Write an SQL query to find all the...

Active Users Problem

LeetCode 1454. Write an SQL query to find the id...

Winning Candidate Problem

LeetCode 574. Write a sql to find the name of...

Team Scores In Football Tournament Problem

LeetCode 1212. Write an SQL query that selects the team_id,...

Rank Scores Problem

LeetCode 178. Write a SQL query to rank scores. If...

Product Sales Analysis III Problem

LeetCode 1070. Write an SQL query that selects the product...

Movie Rating Problem

LeetCode 1341. Write the following SQL query to find the...

Investments In 2016 Problem

LeetCode 585. Write a query to print the sum of...

Immediate Food Delivery II Problem

LeetCode 1174. Write an SQL query to find the percentage...

Friend Requests II: Who Has The Most Friends Problem

LeetCode 602. In social network like Facebook or Twitter, people...

Countries You Can Safely Invest In Problem

LeetCode 1501. Write an SQL query to find the countries...

Count Student Number In Departments Problem

LeetCode 580. A university uses 2 data tables, student and...

Bank Account Summary Problem

LeetCode 1555. Our bank records all transactions in the table...

Tree Node Problem

LeetCode 608. Given a table tree, id is identifier of...

The Most Recent Orders For Each Product Problem

LeetCode 1549. Write an SQL query to find the most...

Shortest Distance In A Plane Problem

LeetCode 612. Write a query to find the shortest distance...

Rectangles Area Problem

LeetCode 1459. Write an SQL query to report of all...

Product Price At A Given Date Problem

LeetCode 1164. Write an SQL query to find the prices...

Page Recommendations Problem

LeetCode 1264. Write an SQL query to recommend pages to...

Monthly Transactions I Problem

LeetCode 1193. Write an SQL query to find for each...

Market Analysis I Problem

LeetCode 1158. Write an SQL query to find for each...

Managers With At Least 5 Direct Reports Problem

LeetCode 570. Given the Employee table, write a SQL query...

Find The Missing IDs Problem

LeetCode 1613. Write an SQL query to find the missing...

Exchange Seats Problem

LeetCode 626. Mary is a teacher in a middle school...

Customers Who Bought All Products Problem

LeetCode 1045. Write an SQL query for a report that...

Active Business Problem

LeetCode 1126. Write an SQL query to find all active...

The Most Recent Three Orders Problem

LeetCode 1532. Write an SQL query to find the most...

Restaurant Growth Problem

LeetCode 1321. You are the restaurant owner and you want...

Project Employees III Problem

LeetCode 1077. Write an SQL query that reports the most...

Number Of Trusted Contacts Of A Customer Problem

LeetCode 1364. Write an SQL query to find the following...

NPV Queries Problem

LeetCode 1421. Write an SQL query to find the npv...

Last Person To Fit In The Elevator Problem

LeetCode 1204. Write an SQL query to find the person_name...

Highest Grade For Each Student Problem

LeetCode 1112. Write a SQL query to find the highest...

Evaluate Boolean Expression Problem

LeetCode 1440. Write an SQL query to evaluate the boolean...

Calculate Salaries Problem

LeetCode 1468. Write an SQL query to find the salaries...

Activity Participants Problem

LeetCode 1355. Write an SQL query to find the names...

User Activity For The Past 30 Days II Problem

LeetCode 1142. Write an SQL query to find the average...

The Most Frequently Ordered Products For Each Customer Problem

LeetCode 1596. Write an SQL query to find the most...

Running Total For Different Genders Problem

LeetCode 1308. Write an SQL query to find the total...

Friendly Movies Streamed Last Month Problem

LeetCode 1495. Write an SQL query to report the distinct...

Friend Requests I: Overall Acceptance Rate Problem

LeetCode 597. Write an SQL query to find the overall...

Find The Start And End Number Of Continuous Ranges Problem

LeetCode 1285. Write an SQL query to find the start...

Customers Who Bought Products A And B But Not C Problem

LeetCode 1398. Write an SQL query to report the customer_id...

Classes More Than 5 Students Problem

LeetCode 596. Please list out all classes which have more...

Capital Gain/Loss Problem

LeetCode 1393. Write an SQL query to report the Capital...

Biggest Single Number Problem

LeetCode 619. Table my_numbers contains many numbers in column num...

Apples & Oranges Problem

LeetCode 1445. Write an SQL query to report the difference...

All People Report To The Given Manager Problem

LeetCode 1270. Write an SQL query to find employee_id of...

Weather Type In Each Country Problem

LeetCode 1294. Write an SQL query to find the type...

User Activity For The Past 30 Days I Problem

LeetCode 1141. Write an SQL query to find the daily...

Triangle Judgement Problem

LeetCode 610. A pupil Tim gets homework to identify whether...

Students And Examinations Problem

LeetCode 1280. Write an SQL query to find the number...

Sales Person Problem

LeetCode 607. Given three tables, salesperson, company, orders.

Sales Analysis III Problem

LeetCode 1084. Write an SQL query that reports the products...

Sales Analysis II Problem

LeetCode 1083. Write an SQL query that reports the buyers...

Reported Posts Problem

LeetCode 1113. Write an SQL query that reports the number...

Queries Quality And Percentage Problem

LeetCode 1211. Write an SQL query to find each query_name,...

Project Employees II Problem

LeetCode 1076. Write an SQL query that reports all the...

Project Employees I Problem

LeetCode 1075. Write an SQL query that reports the average...

Number Of Comments Per Post Problem

LeetCode 1241. Write an SQL query to find number of...

Not Boring Movies Problem

LeetCode 620. X city opened a new cinema, many people...

Fix Product Name Format Problem

LeetCode 1543. Write an SQL query to report product_name in...

Consecutive Available Seats Problem

LeetCode 603. Several friends at a cinema ticket office would...

Ads Performance Problem

LeetCode 1322. A company is running Ads and wants to...

Top Travellers Problem

LeetCode 1407. Write an SQL query to report the distance...

Swap Salary Problem

LeetCode 627. Given a table salary, such as the one...

Shortest Distance Problem

LeetCode 613. Write a query to find the shortest distance...

Sales Analysis I Problem

LeetCode 1082. Write an SQL query that reports the best...

Reformat Department Table Problem

LeetCode 1179. Write an SQL query to reformat the table...

Product Sales Analysis II Problem

LeetCode 1069. Write an SQL query that reports the total...

Product Sales Analysis I Problem

LeetCode 1068. Write an SQL query that reports all product...

List The Products Ordered In A Period Problem

LeetCode 1327. Write an SQL query to get the names...

Immediate Food Delivery I Problem

LeetCode 1173. Write an SQL query to find the percentage...

Find Users With Valid Emails Problem

LeetCode 1517. Write an SQL query to find the users...

Find Customer Referee Problem

LeetCode 584. Given a table customer holding customers information and...

Customer Placing The Largest Number Of Orders Problem

LeetCode 586. Query the customer_number from the orders table for...

Customer Order Frequency Problem

LeetCode 1511. Write an SQL query to report the customer_id...

Create A Session Bar Chart Problem

LeetCode 1435. You want to know how long a user...

Big Countries Problem

LeetCode 595. Write a SQL solution to output big countries’...

Average Selling Price Problem

LeetCode 1251. Write an SQL query to find the average...

Article Views I Problem

LeetCode 1148. Write an SQL query to find all the...

Actors And Directors Who Cooperated At Least Three Times Problem

LeetCode 1050. Write a SQL query for a report that...

Unique Orders And Customers Per Month Problem

LeetCode 1565. Write an SQL query to find the number...

Sellers With No Sales Problem

LeetCode 1607. Write an SQL query to report the names...

Rising Temperature Problem

LeetCode 197. Write an SQL query to find all dates’...

Game Play Analysis IV Problem

LeetCode 550. Write an SQL query that reports the fraction...

Game Play Analysis III Problem

LeetCode 534. Write an SQL query that reports for each...

Game Play Analysis II Problem

LeetCode 512. Write a SQL query that reports the device...

Game Play Analysis I Problem

LeetCode 511. Write an SQL query that reports the first...

Employee Bonus Problem

LeetCode 577. Select all employee’s name and bonus whose bonus...

Delete Duplicate Emails Problem

LeetCode 196. Write a SQL query to delete all duplicate...

Daily Leads And Partners Problem

LeetCode 1693. Write an SQL query that will, for each...

Customer Who Visited But Did Not Make Any Transactions Problem

LeetCode 1581. Write an SQL query to find the IDs...

Product's Worth Over Invoices Problem

LeetCode 1677. Write an SQL query that will, for all...

Percentage Of Users Attended A Contest Problem

LeetCode 1633. Write an SQL query to find the percentage...

Fix Names In A Table Problem

LeetCode 1667. Write an SQL query to fix the names...

Duplicate Emails Problem

LeetCode 182. Write a SQL query to find all duplicate...

Customers Who Never Order Problem

LeetCode 183. Write a SQL query to find all customers...

Consecutive Numbers Problem

LeetCode 180. Write an SQL query to find all numbers...

Average Time Of Process Per Machine Problem

LeetCode 1661. There is a factory website that has several...

Second Highest Salary Problem

LeetCode 176. Given the Employee table, write a SQL query...

Employees Earning More Than Their Managers Problem

LeetCode 181. Given the Employee table, write a SQL query...

Bank Account Summary II Problem

LeetCode 1587. Write an SQL query to report the name...

Group Sold Products By The Date Problem

LeetCode 1484. Write an SQL query to find for each...

All Valid Triplets That Can Represent A Country Problem

LeetCode 1623. Write an SQL query to find all the...

Warehouse Manager Problem

LeetCode 1571. Write an SQL query to report how much...

Students With Invalid Departments Problem

LeetCode 1350. Write an SQL query to find the id...

Replace Employee ID With The Unique Identifier Problem

LeetCode 1378. Write an SQL query to show the unique...

Patients With A Condition Problem

LeetCode 1527. Write an SQL query to report the patient_id,...

Invalid Tweets Problem

LeetCode 1683. Write an SQL query to find the IDs...

Find The Team Size Problem

LeetCode 1303. Write an SQL query to find the team...

Combine Two Tables Problem

LeetCode 175. Write a SQL query for a report that...

Maximum Equal Frequency Problem

LeetCode 1224. Given an array nums of positive integers, return...

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Merge Intervals Problem

LeetCode 56. Given an array of intervals, merge all overlapping...

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...

Reverse Linked List Problem

LeetCode 206. Reverse a singly linked list.

Reverse Linked List II Problem

LeetCode 92. Reverse a linked list from position m to...

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Merge Two Sorted Lists Problem

LeetCode 21. Merge two sorted linked lists and return a...

Median of Two Sorted Arrays Problem

LeetCode 4. Given two sorted arrays nums1 and nums2 of...

Valid Perfect Square Problem

LeetCode 367. Given a positive integer num, write a function...

Sqrt(x) Problem

LeetCode 69. Given a non-negative integer x, compute and return...

Search Insert Position Problem

LeetCode 35. Given a sorted array of distinct integers and...

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Implement Trie (Prefix Tree) Problem

LeetCode 208. Implement a Trie with insert, search, and startsWith...

Camelcase Matching Problem

LeetCode 1023. A query word matches a given pattern if...

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Two Sum Input Array Is Sorted Problem

LeetCode 167. Given an array of integers nums sorted in...

Subarray Sum Divisible By K Problem

LeetCode 974. Given an array of integers nums and an...

Replace Words Problem

LeetCode 648. Given a dictionary consisting of many roots, and...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Four Sum II Problem

LeetCode 454. Given four lists A, B, C, D of...

Continuous Subarray Sum Problem

LeetCode 523. Given an array of non-negative integers nums and...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...

Two Sum Less Than K Problem

LeetCode 1099. Given an array of integers nums and an...

Subarray Sum Equals K Problem

LeetCode 560. Given an array of integers nums and an...

Subarray Product Less Than K Problem

LeetCode 713. Given an array of positive integers nums and...

Three Sum Problem

LeetCode 15. Given an array of integers nums, return all...

Four Sum Problem

LeetCode 18. Given an array of integers nums and an...

Two Sum Problem

LeetCode 1. Given an array of integers nums and an...

Tag Two Pointer

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Two Sum Input Array Is Sorted Problem

LeetCode 167. Given an array of integers nums sorted in...

Two Sum Less Than K Problem

LeetCode 1099. Given an array of integers nums and an...

Subarray Product Less Than K Problem

LeetCode 713. Given an array of positive integers nums and...

Three Sum Problem

LeetCode 15. Given an array of integers nums, return all...

Four Sum Problem

LeetCode 18. Given an array of integers nums and an...

Tag Trie

Short Encoding Of Words Problem

LeetCode 820. A valid encoding of an array of words...

Top K Frequent Words Problem

LeetCode 692. Given an array of strings words and an...

Prefix And Suffix Search Problem

LeetCode 745. Design a special dictionary with some words that...

Number Of Matching Subsequences Problem

LeetCode 792. Given a string s and an array of...

Map Sum Pairs Problem

LeetCode 677. Design a map that allows you to do...

Implement Magic Dictionary Problem

LeetCode 676. Design a data structure that is initialized with...

Palindrome Pairs Problem

LeetCode 336. Given a list of unique words, return all...

Lexicographical Numbers Problem

LeetCode 386. Given an integer n, return all the numbers...

Design Add And Search Words Data Structure Problem

LeetCode 211. Design a data structure that supports adding new...

Word Break Problem

LeetCode 139. Given a string s and a dictionary of...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Implement Trie (Prefix Tree) Problem

LeetCode 208. Implement a Trie with insert, search, and startsWith...

Camelcase Matching Problem

LeetCode 1023. A query word matches a given pattern if...

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Replace Words Problem

LeetCode 648. Given a dictionary consisting of many roots, and...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...


Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...

Tag Backtracking

Unique Paths III Problem

LeetCode 980. You are given an m x n integer...

Split Array Into Fibonacci Sequence Problem

LeetCode 842. You are given a string of digits num,...

Numbers With Same Consecutive Differences Problem

LeetCode 967. Return all non-negative integers of length n such...

Number Of Squareful Arrays Problem

LeetCode 996. An array is squareful if the sum of...

Ambiguous Coordinates Problem

LeetCode 816. We had some 2-dimensional coordinates, like “(1, 3)”...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Letter Case Permutation Problem

LeetCode 784. Given a string s, we can transform every...

All Paths From Source To Target Problem

LeetCode 797. Given a directed acyclic graph (DAG) of n...

24 Game Problem

LeetCode 679. You are given an integer array cards of...

Target Sum Problem

LeetCode 494. You are given an integer array nums and...

Matchsticks To Square Problem

LeetCode 473. You are given an integer array matchsticks where...

Increasing Subsequences Problem

LeetCode 491. Given an integer array nums, return all the...

Binary Watch Problem

LeetCode 401. A binary watch has 4 LEDs on the...

Beautiful Arrangement Problem

LeetCode 526. Suppose you have n integers labeled 1 through...

Remove Invalid Parentheses Problem

LeetCode 301. Given a string s that contains parentheses and...

Expression Add Operators Problem

LeetCode 282. Given a string num that contains only digits...

Count Numbers With Unique Digits Problem

LeetCode 357. Given an integer n, return the count of...

Combination Sum III Problem

LeetCode 216. Find all valid combinations of k numbers that...

Binary Tree Paths Problem

LeetCode 257. Given the root of a binary tree, return...

Additive Number Problem

LeetCode 306. Additive number is a string whose digits can...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Palindrome Partitioning Problem

LeetCode 131. Given a string s, partition s such that...

Word Ladder II Problem

LeetCode 126. Given two words, beginWord and endWord, and a...

Word Search Problem

LeetCode 79. Given an m x n grid of characters...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Subsets Problem

LeetCode 78. Given an integer array nums of unique elements,...

Subsets II Problem

LeetCode 90. Given an integer array nums that may contain...

Restore IP Addresses Problem

LeetCode 93. Given a string s containing only digits, return...

Gray Code Problem

LeetCode 89. Given an integer n, return any valid n-bit...

Combinations Problem

LeetCode 77. Given two integers n and k, return all...

N-Queens Problem

LeetCode 51. Given an integer n, return all distinct solutions...

N-Queens II Problem

LeetCode 52. Given an integer n, return the number of...

Sudoku Solver Problem

LeetCode 37. Write a program to solve a Sudoku puzzle...

Permutations Problem

LeetCode 46. Given an array nums of distinct integers, return...

Permutations II Problem

LeetCode 47. Given a collection of numbers, nums, that might...

Combination Sum Problem

LeetCode 39. Given an array of distinct integers candidates and...

Combination Sum II Problem

LeetCode 40. Given a collection of candidate numbers (candidates) and...

Letter Combinations of a Phone Number Problem

LeetCode 17. Given a string containing digits from 2-9 inclusive,...

Generate Parentheses Problem

LeetCode 22. Given n pairs of parentheses, write a function...

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Tag Greedy

String Without Aaa Or Bbb Problem

LeetCode 984. Given two integers a and b, return any...

Stamping The Sequence Problem

LeetCode 936. You are given two strings stamp and target....

Smallest Range II Problem

LeetCode 910. You are given an integer array nums and...

Score After Flipping Matrix Problem

LeetCode 861. You are given an m x n binary...

Pancake Sorting Problem

LeetCode 969. Given an array of integers arr, sort the...

Most Profit Assigning Work Problem

LeetCode 826. You have n jobs and m workers. You...

Minimum Number Of Refueling Stops Problem

LeetCode 871. A car travels from a starting position to...

Minimum Increment To Make Array Unique Problem

LeetCode 945. You are given an integer array nums. In...

Minimum Cost To Hire K Workers Problem

LeetCode 857. There are n workers. You are given two...

Minimum Add To Make Parentheses Valid Problem

LeetCode 921. A parentheses string is valid if and only...

Max Increase To Keep City Skyline Problem

LeetCode 807. There is a city composed of n x...

Lemonade Change Problem

LeetCode 860. At a lemonade stand, each lemonade costs $5....

Largest Perimeter Triangle Problem

LeetCode 976. Given an integer array nums, return the largest...

Hand Of Straights Problem

LeetCode 846. Alice has some number of cards and she...

DI String Match Problem

LeetCode 942. A permutation perm of n + 1 integers...

Delete Columns To Make Sorted II Problem

LeetCode 955. You are given an array of n strings...

Broken Calculator Problem

LeetCode 991. There is a broken calculator that has the...

Boats To Save People Problem

LeetCode 881. You are given an array people where people[i]...

Bag Of Tokens Problem

LeetCode 948. You have an initial power of power, an...

Array Of Doubled Pairs Problem

LeetCode 954. Given an integer array of even length arr,...

Advantage Shuffle Problem

LeetCode 870. You are given two integer arrays nums1 and...

Valid Triangle Number Problem

LeetCode 611. Given an integer array nums, return the number...

Valid Parenthesis String Problem

LeetCode 678. Given a string s containing only three types...

Valid Palindrome II Problem

LeetCode 680. Given a string s, return true if the...

Task Scheduler Problem

LeetCode 621. Given a characters array tasks, representing the tasks...

Set Intersection Size At Least Two Problem

LeetCode 757. You are given a 2D integer array intervals...

Reorganize String Problem

LeetCode 767. Given a string s, rearrange the characters of...

Rabbits In Forest Problem

LeetCode 781. There is a forest with an unknown number...

Partition Labels Problem

LeetCode 763. You are given a string s. We want...

Dota2 Senate Problem

LeetCode 649. In the world of Dota2, there are two...

Split Array Into Consecutive Subsequences Problem

LeetCode 659. You are given an integer array nums that...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Monotone Increasing Digits Problem

LeetCode 738. An integer has monotone increasing digits if and...

Maximum Length Of Pair Chain Problem

LeetCode 646. You are given an array of n pairs...

Max Chunks To Make Sorted Problem

LeetCode 769. You are given an integer array arr of...

Max Chunks To Make Sorted II Problem

LeetCode 768. You are given an integer array arr.

Maximum Swap Problem

LeetCode 670. You are given an integer num. You can...

Course Schedule III Problem

LeetCode 630. There are n different online courses numbered from...

Couples Holding Hands Problem

LeetCode 765. There are n couples sitting in 2n seats...

Can Place Flowers Problem

LeetCode 605. You have a long flowerbed in which some...

Super Washing Machines Problem

LeetCode 517. You have n super washing machines on a...

Strong Password Checker Problem

LeetCode 420. A password is considered strong if the below...

IPO Problem

LeetCode 502. Suppose LeetCode will start its IPO soon. In...

Split Array Largest Sum Problem

LeetCode 410. Given an array nums which consists of non-negative...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Remove K Digits Problem

LeetCode 402. Given string num representing a non-negative integer num,...

Queue Reconstruction By Height Problem

LeetCode 406. You are given an array of people, people,...

Non-Overlapping Intervals Problem

LeetCode 435. Given an array of intervals intervals where intervals[i]...

Minimum Number Of Arrows To Burst Balloons Problem

LeetCode 452. There are some spherical balloons taped onto a...

Longest Palindrome Problem

LeetCode 409. Given a string s which consists of lowercase...

Assign Cookies Problem

LeetCode 455. Assume you are an awesome parent and want...

Array Partition I Problem

LeetCode 561. Given an integer array nums of 2n integers,...

Wiggle Subsequence Problem

LeetCode 376. A wiggle sequence is a sequence where the...

Remove Duplicate Letters Problem

LeetCode 316. Given a string s, remove duplicate letters so...

Patching Array Problem

LeetCode 330. Given a sorted integer array nums and an...

Integer Replacement Problem

LeetCode 397. Given a positive integer n,you can apply one...

Increasing Triplet Subsequence Problem

LeetCode 334. Given an integer array nums, return true if...

Create Maximum Number Problem

LeetCode 321. You are given two integer arrays nums1 and...

Largest Number Problem

LeetCode 179. Given a list of non-negative integers nums, arrange...

Gas Station Problem

LeetCode 134. There are n gas stations along a circular...

Candy Problem

LeetCode 135. There are n children standing in a line....

Best Time To Buy And Sell Stock Ii Problem

LeetCode 122. You are given an integer array prices where...

Jump Game Problem

LeetCode 55. Given an m x n matrix, return all...

Wildcard Matching Problem

LeetCode 44. Write the code that will take a string...

Jump Game II Problem

LeetCode 45. Given an array of non-negative integers nums, you...

Container With Most Water Problem

LeetCode 11. Given n non-negative integers a_1, a_2, …, a_n...

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Tag Queue

Stamping The Sequence Problem

LeetCode 936. You are given two strings stamp and target....

Shortest Subarray With Sum At Least K Problem

LeetCode 862. Given an integer array nums and an integer...

Reveal Cards In Increasing Order Problem

LeetCode 950. You are given an integer array deck. There...

Number Of Recent Calls Problem

LeetCode 933. You have a RecentCounter class which counts the...

Maximum Sum Circular Subarray Problem

LeetCode 918. Given a circular integer array nums of length...

Dota2 Senate Problem

LeetCode 649. In the world of Dota2, there are two...

Design Circular Queue Problem

LeetCode 622. Design your implementation of the circular queue. The...

Design Circular Deque Problem

LeetCode 641. Design your implementation of the circular double-ended queue...

Sliding Window Maximum Problem

LeetCode 239. You are given an array of integersnums, there...

Implement Stack Using Queues Problem

LeetCode 225. Implement a last-in-first-out (LIFO) stack using only two...

Implement Queue Using Stacks Problem

LeetCode 232. Implement a first in first out (FIFO) queue...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

First Unique Character In A String Problem

LeetCode 387. Given a string s, find the first non-repeating...

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...


Time Based Key-Value Store Problem

LeetCode 981. Design a time-based key-value data structure that can...

Super Egg Drop Problem

LeetCode 887. You are given k identical eggs and you...

Shortest Subarray With Sum At Least K Problem

LeetCode 862. Given an integer array nums and an integer...

Peak Index In A Mountain Array Problem

LeetCode 852. Let’s call an array arr a mountainif the...

Online Election Problem

LeetCode 911. You are given two integer arrays persons and...

Numbers At Most N Given Digit Set Problem

LeetCode 902. Given an array of digits which is sorted...

Nth Magical Number Problem

LeetCode 878. A positive integer is magical if it is...

Most Profit Assigning Work Problem

LeetCode 826. You have n jobs and m workers. You...

Koko Eating Bananas Problem

LeetCode 875. Koko loves to eat bananas. There are n...

Friends Of Appropriate Ages Problem

LeetCode 825. There are n persons on a social media...

Fair Candy Swap Problem

LeetCode 888. Alice and Bob have a different total number...

Valid Triangle Number Problem

LeetCode 611. Given an integer array nums, return the number...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Random Pick With Blacklist Problem

LeetCode 710. You are given an integer n and an...

My Calendar III Problem

LeetCode 732. A k-booking happens when k events have some...

My Calendar II Problem

LeetCode 731. You are implementing a program to use as...

My Calendar I Problem

LeetCode 729. You are implementing a program to use as...

Sum Of Square Numbers Problem

LeetCode 633. Given a non-negative integer c, decide whether there’re...

Reach A Number Problem

LeetCode 754. You are standing at position 0 on an...

Maximum Length Of Repeated Subarray Problem

LeetCode 718. Given two integer arrays nums1 and nums2, return...

Kth Smallest Number In Multiplication Table Problem

LeetCode 668. Nearly everyone has used the Multiplication Table. The...

Find Smallest Letter Greater Than Target Problem

LeetCode 744. Given a characters array letters that is sorted...

K-Th Smallest Prime Fraction Problem

LeetCode 786. You are given a sorted integer array arr...

Find K-Th Smallest Pair Distance Problem

LeetCode 719. The distance of a pair of integers a...

Find K Closest Elements Problem

LeetCode 658. Given a sorted integer array arr, two integers...

Binary Search Problem

LeetCode 704. Given an array of integers nums which is...

Random Point In Non-Overlapping Rectangles Problem

LeetCode 497. You are given an array of non-overlapping axis-aligned...

Split Array Largest Sum Problem

LeetCode 410. Given an array nums which consists of non-negative...

Smallest Good Base Problem

LeetCode 483. Given an integer n represented as a string,...

Single Element In A Sorted Array Problem

LeetCode 540. You are given a sorted array consisting of...

Reverse Pairs Problem

LeetCode 493. Given an integer array nums, return the number...

Random Pick With Weight Problem

LeetCode 528. You are given a 0-indexed array of positive...

Most Frequent Subtree Sum Problem

LeetCode 508. Given the root of a binary tree, return...

K-Diff Pairs In An Array Problem

LeetCode 532. Given an array of integers nums and an...

Heaters Problem

LeetCode 475. Winter is coming! During the contest, your first...

Arranging Coins Problem

LeetCode 441. You have n coins and you want to...

132 Pattern Problem

LeetCode 456. Given an arrayof n integers nums, a 132...

Search A 2D Matrix II Problem

LeetCode 240. Write an efficient algorithm that searches for a...

Nth Digit Problem

LeetCode 400. Given an integer n, return the n^th digit...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Minimum Size Subarray Sum Problem

LeetCode 209. Given an array of positive integers nums and...

Longest Increasing Subsequence Problem

LeetCode 300. Given an integer array nums, return the length...

Intersection Of Two Arrays II Problem

LeetCode 350. Given two integer arrays nums1 and nums2, return...

H-Index II Problem

LeetCode 275. Given an array of integers citations where citations[i]...

Guess Number Higher Or Lower Problem

LeetCode 374. We are playing the Guess Game. The game...

First Bad Version Problem

LeetCode 278. You are a product manager and currently leading...

Find The Duplicate Number Problem

LeetCode 287. Given an array of integers nums containingn +...

Data Stream As Disjoint Intervals Problem

LeetCode 352. Given a data stream input of non-negative integers...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Count Complete Tree Nodes Problem

LeetCode 222. Given the root of a complete binary tree,...

Find Peak Element Problem

LeetCode 162. A peak element is an element that is...

Find Minimum In Rotated Sorted Array Problem

LeetCode 153. Suppose an array of length n sorted in...

Find Minimum In Rotated Sorted Array II Problem

LeetCode 154. Suppose an array of length n sorted in...

Search in Rotated Sorted Array II Problem

LeetCode 81. There is an integer array nums sorted in...

Search A 2D Matrix Problem

LeetCode 74. Write an efficient algorithm that searches for a...

Find First and Last Position of Element in Sorted Array Problem

LeetCode 34. Given the array nums after the possible rotation...

Median of Two Sorted Arrays Problem

LeetCode 4. Given two sorted arrays nums1 and nums2 of...

Valid Perfect Square Problem

LeetCode 367. Given a positive integer num, write a function...

Sqrt(x) Problem

LeetCode 69. Given a non-negative integer x, compute and return...

Search Insert Position Problem

LeetCode 35. Given a sorted array of distinct integers and...

Tag C++

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Lambda Expressions in C++

A lambda expression is a convenient way of defining an...

Template Specializations in C++

A template specialization is a separate definition in which the...

Implicit Type Conversions in C++

C++ transforms the operands to a common type before performing...

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...

Copy Constructors in C++

The constructor that takes a single parameter that is a...

Inline Functions in C++

A function specified as inline is expanded everywhere it is...

Function Pointers in C++

A function pointer is a pointer that denotes a function...

Online Book Reader System Problem

Design the data structures for an online book reader system...

Parking Lot Problem

Design a parking lot using object-oriented principles. We will focus...

Call Center Problem

An object oriented design problem. Imagine you have a call...

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Factory Design Pattern

The factory design pattern is a type of creational pattern...

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Friend Class and Function in C++

A friend class can access private and protected members of...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Templates in C++

A template is a blueprint or formula for creating a...

Polymorphism in C++

Polymorphism means having more than one function with the same...

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Interface

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Abstract Class

Interfaces in C++

An interface describes the behavior or capabilities of a C++...


Tag Pure Virtual Function

Polymorphism in C++

Polymorphism means having more than one function with the same...

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Concrete Class

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Polymorphism

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Overload

Polymorphism in C++

Polymorphism means having more than one function with the same...


Tag Override

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Virtual Function

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Template

Template Specializations in C++

A template specialization is a separate definition in which the...

Templates in C++

A template is a blueprint or formula for creating a...

Tag Function Template

Templates in C++

A template is a blueprint or formula for creating a...


Tag Class Template

Templates in C++

A template is a blueprint or formula for creating a...

Tag Smart Pointers

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Tag RAII

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Tag Shared_Ptr

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...


Tag Raw Pointers

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Unique_Ptr

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Weak_Ptr

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Friend Class

Friend Class and Function in C++

A friend class can access private and protected members of...


Tag Friend Function

Friend Class and Function in C++

A friend class can access private and protected members of...

Tag Cyclic Reference

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Tag Weak Reference

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Tag Factory Pattern

Factory Design Pattern

The factory design pattern is a type of creational pattern...


Tag Creational Pattern

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Factory Design Pattern

The factory design pattern is a type of creational pattern...

Tag Singleton Pattern

Call Center Problem

An object oriented design problem. Imagine you have a call...

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Tag OOD

Online Book Reader System Problem

Design the data structures for an online book reader system...

Parking Lot Problem

Design a parking lot using object-oriented principles. We will focus...

Call Center Problem

An object oriented design problem. Imagine you have a call...

Tag Linked List

Middle Of The Linked List Problem

LeetCode 876. Given the head of a singly linked list,...

Linked List Components Problem

LeetCode 817. You are given the head of a linked...

Split Linked List In Parts Problem

LeetCode 725. Given the head of a singly linked list...

Design Circular Queue Problem

LeetCode 622. Design your implementation of the circular queue. The...

Design Circular Deque Problem

LeetCode 641. Design your implementation of the circular double-ended queue...

Design Linked List Problem

LeetCode 707. Design your implementation of the linked list. You...

Design Hashset Problem

LeetCode 705. Design a HashSet without using any built-in hash...

Design Hashmap Problem

LeetCode 706. Design a HashMap without using any built-in hash...

LFU Cache Problem

LeetCode 460. Design and implement a data structure for a...

All O'One Data Structure Problem

LeetCode 432. Design a data structure to store the strings...

Add Two Numbers II Problem

LeetCode 445. You are given two non-empty linked lists representing...

Remove Linked List Elements Problem

LeetCode 203. Given the head of a linked list and...

Odd Even Linked List Problem

LeetCode 328. Given the head of a singly linked list,...

Linked List Random Node Problem

LeetCode 382. Given a singly linked list, return a random...

Design Twitter Problem

LeetCode 355. Design a simplified version of Twitter where users...

Delete Node In A Linked List Problem

LeetCode 237. Write a function to delete a node in...

Intersection Of Two Linked Lists Problem

LeetCode 160. Given the heads of two singly linked-lists headA...

Sort List Problem

LeetCode 148. Given the head of a linked list, return...

Reorder List Problem

LeetCode 143. You are given the head of a singly...

Lru Cache Problem

LeetCode 146. Design a data structure that follows the constraints...

Linked List Cycle Problem

LeetCode 141. Given head, the head of a linked list,...

Linked List Cycle II Problem

LeetCode 142. Given the head of a linked list, return...

Insertion Sort List Problem

LeetCode 147. Given the head of a singly linked list,...

Copy List With Random Pointer Problem

LeetCode 138. A linked list of length n is given...

Flatten Binary Tree To Linked List Problem

LeetCode 114. Given the root of a binary tree, flatten...

Remove Duplicates from Sorted List Problem

LeetCode 83. Given the head of a sorted linked list,...

Remove Duplicates from Sorted List II Problem

LeetCode 82. Given the head of a sorted linked list,...

Partition List Problem

LeetCode 86. Given the head of a linked list and...

Rotate List Problem

LeetCode 61. Given the head of a linked list, rotate...

Reverse Nodes in k-Group Problem

LeetCode 25. Given a linked list, reverse the nodes of...

Swap Nodes in Pairs Problem

LeetCode 24. Given a linked list, swap every two adjacent...

Remove Nth Node From End of List Problem

LeetCode 19. Given the head of a linked list, remove...

Add Two Numbers Problem

LeetCode 2. You are given two non-empty linked lists representing...

Reverse Linked List Problem

LeetCode 206. Reverse a singly linked list.

Reverse Linked List II Problem

LeetCode 92. Reverse a linked list from position m to...

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Merge Two Sorted Lists Problem

LeetCode 21. Merge two sorted linked lists and return a...


Tag Priority Queue

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Tag Virtual Memory

Virtual Memory VIII: Page Replacement Policies

How can the OS decide which page(s) to evict from...

Virtual Memory V: TLBs

How can we speed up address translation, and generally avoid...

Virtual Memory IV: Paging

How can we virtualize memory with pages, so as to...

Virtual Memory III: Segmentation

How to support a large address space with (potentially) a...

Virtual Memory II: Address Translation

How can we relocate the process in memory in a...

Virtual Memory I: Overview

Virtual Memory is an abstraction that the Operating System provides...

Tag Function Pointers

Function Pointers in C++

A function pointer is a pointer that denotes a function...

Tag Pointers to Functions

Function Pointers in C++

A function pointer is a pointer that denotes a function...


Tag Inline Functions

Inline Functions in C++

A function specified as inline is expanded everywhere it is...

Tag Process

Process I: The Abstraction

How can the OS provide the illusion of nearly-endless supply...

Tag Copy Constructors

Copy Constructors in C++

The constructor that takes a single parameter that is a...

Tag Tree

Vertical Order Traversal Of A Binary Tree Problem

LeetCode 987. Given the root of a binary tree, calculate...

Univalued Binary Tree Problem

LeetCode 965. A binary tree is uni-valued if every node...

Sum Of Distances In Tree Problem

LeetCode 834. There is an undirected connected tree with n...

Smallest Subtree With All The Deepest Nodes Problem

LeetCode 865. Given the root of a binary tree, the...

Smallest String Starting From Leaf Problem

LeetCode 988. You are given the root of a binary...

Range Sum Of BST Problem

LeetCode 938. Given the root node of a binary search...

Maximum Binary Tree II Problem

LeetCode 998. A maximum tree is a tree where every...

Leaf-Similar Trees Problem

LeetCode 872. Consider all the leaves of a binary tree,...

Increasing Order Search Tree Problem

LeetCode 897. Given the root of a binary search tree,...

Flip Equivalent Binary Trees Problem

LeetCode 951. For a binary tree T, we can define...

Distribute Coins In Binary Tree Problem

LeetCode 979. You are given the root of a binary...

Cousins In Binary Tree Problem

LeetCode 993. Given the root of a binary tree with...

Construct Binary Tree From Preorder And Postorder Traversal Problem

LeetCode 889. Given two integer arrays, preorder and postorder where...

Complete Binary Tree Inserter Problem

LeetCode 919. A complete binary tree is a binary tree...

Check Completeness Of A Binary Tree Problem

LeetCode 958. Given the root of a binary tree, determine...

Binary Tree Pruning Problem

LeetCode 814. Given the root of a binary tree, return...

Binary Tree Cameras Problem

LeetCode 968. You are given the root of a binary...

All Possible Full Binary Trees Problem

LeetCode 894. Given an integer n, return a list of...

All Nodes Distance K In Binary Tree Problem

LeetCode 863. Given the root of a binary tree, the...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Trim A Binary Search Tree Problem

LeetCode 669. Given the root of a binary search tree...

Second Minimum Node In A Binary Tree Problem

LeetCode 671. Given a non-empty special binary tree consisting of...

Search In A Binary Search Tree Problem

LeetCode 700. You are given the root of a binary...

Print Binary Tree Problem

LeetCode 655. Given the root of a binary tree, construct...

Minimum Distance Between BST Nodes Problem

LeetCode 783. Given the root of a Binary Search Tree...

Merge Two Binary Trees Problem

LeetCode 617. You are given two binary trees root1 and...

Maximum Width Of Binary Tree Problem

LeetCode 662. Given the root of a binary tree, return...

Longest Univalue Path Problem

LeetCode 687. Given the root of a binary tree, return...

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

Find Duplicate Subtrees Problem

LeetCode 652. Given the rootof a binary tree, return all...

Construct String From Binary Tree Problem

LeetCode 606. Given the root of a binary tree, construct...

Average Of Levels In Binary Tree Problem

LeetCode 637. Given the root of a binary tree, return...

Add One Row To Tree Problem

LeetCode 623. Given the root of a binary tree and...

Sum Of Left Leaves Problem

LeetCode 404. Given the root of a binary tree, return...

Subtree Of Another Tree Problem

LeetCode 572. Given the roots of two binary trees root...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Path Sum III Problem

LeetCode 437. Given the root of a binary tree and...

N-Ary Tree Preorder Traversal Problem

LeetCode 589. Given the root of an n-ary tree, return...

N-Ary Tree Postorder Traversal Problem

LeetCode 590. Given the root of an n-ary tree, return...

N-Ary Tree Level Order Traversal Problem

LeetCode 429. Given an n-ary tree, return the level order...

Most Frequent Subtree Sum Problem

LeetCode 508. Given the root of a binary tree, return...

Minimum Absolute Difference In BST Problem

LeetCode 530. Given the root of a Binary Search Tree...

Maximum Depth Of N-Ary Tree Problem

LeetCode 559. Given a n-ary tree, find its maximum depth....

Find Mode In Binary Search Tree Problem

LeetCode 501. Given the root of a binary search tree...

Find Largest Value In Each Tree Row Problem

LeetCode 515. Given the root of a binary tree, return...

Find Bottom Left Tree Value Problem

LeetCode 513. Given the root of a binary tree, return...

Delete Node In A BST Problem

LeetCode 450. Given a root node reference of a BST...

Convert BST To Greater Tree Problem

LeetCode 538. Given the root of a Binary Search Tree...

Construct Quad Tree Problem

LeetCode 427. Given a n * n matrix grid of...

Binary Tree Tilt Problem

LeetCode 563. Given the root of a binary tree, return...

Verify Preorder Serialization Of A Binary Tree Problem

LeetCode 331. One way to serialize a binary tree is...

Serialize And Deserialize Binary Tree Problem

LeetCode 297. Serialization is the process of converting a data...

Lowest Common Ancestor Of A Binary Tree Problem

LeetCode 236. Given a binary tree, find the lowest common...

Lowest Common Ancestor Of A Binary Search Tree Problem

LeetCode 235. Given a binary search tree (BST), find the...

Kth Smallest Element In A BST Problem

LeetCode 230. Given the root of a binary search tree,...

Invert Binary Tree Problem

LeetCode 226. Given the root of a binary tree, invert...

House Robber III Problem

LeetCode 337. The thief has found himself a new place...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

Count Complete Tree Nodes Problem

LeetCode 222. Given the root of a complete binary tree,...

Binary Tree Paths Problem

LeetCode 257. Given the root of a binary tree, return...

Binary Tree Right Side View Problem

LeetCode 199. Given the root of a binary tree, imagine...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Binary Tree Preorder Traversal Problem

LeetCode 144. Given the root of a binary tree, return...

Binary Tree Postorder Traversal Problem

LeetCode 145. Given the root of abinary tree, return the...

Sum Root To Leaf Numbers Problem

LeetCode 129. You are given the root of a binary...

Populating Next Right Pointers In Each Node Problem

LeetCode 116. You are given a perfect binary tree where...

Populating Next Right Pointers In Each Node II Problem

LeetCode 117. Given a binary tree, populate each next pointer...

Path Sum Problem

LeetCode 112. Given the root of a binary tree and...

Path Sum II Problem

LeetCode 113. Given the root of a binary tree and...

Minimum Depth Of Binary Tree Problem

LeetCode 111. Given a binary tree, find its minimum depth....

Flatten Binary Tree To Linked List Problem

LeetCode 114. Given the root of a binary tree, flatten...

Balanced Binary Tree Problem

LeetCode 110. Given a binary tree, determine if it is...

Symmetric Tree Problem

LeetCode 101. Given the root of a binary tree, check...

Maximum Depth of Binary Tree Problem

LeetCode 104. Given the root of a binary tree, return...

Convert Sorted Array to Binary Search Tree Problem

LeetCode 108. Given an integer array nums where the elements...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Construct Binary Tree From Inorder And Postorder Traversal Problem

LeetCode 106. Given two integer arrays inorder and postorder where...

Binary Tree Zigzag Level Order Traversal Problem

LeetCode 103. Given the root of a binary tree, return...

Binary Tree Level Order Traversal Problem

LeetCode 102. Given the root of a binary tree, return...

Binary Tree Level Order Traversal II Problem

LeetCode 107. Given the root of a binary tree, return...

Validate Binary Search Tree Problem

LeetCode 98. Given the root of a binary tree, determine...

Same Tree Problem

LeetCode 100. Given the roots of two binary trees p...

Recover Binary Search Tree Problem

LeetCode 99. You are given the root of a binary...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Binary Tree Inorder Traversal Problem

LeetCode 94. Given an m x n grid of characters...

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...


Tag Sliding Window

Subarrays With K Different Integers Problem

LeetCode 992. Given an integer array nums and an integer...

Shortest Subarray With Sum At Least K Problem

LeetCode 862. Given an integer array nums and an integer...

New 21 Game Problem

LeetCode 837. Alice plays the following game, loosely based on...

Longest Turbulent Subarray Problem

LeetCode 978. Given an integer array arr, return the length...

Fruit Into Baskets Problem

LeetCode 904. You are visiting a farm that has a...

Binary Subarrays With Sum Problem

LeetCode 930. Given a binary array nums and an integer...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Maximum Length Of Repeated Subarray Problem

LeetCode 718. Given two integer arrays nums1 and nums2, return...

Maximum Average Subarray I Problem

LeetCode 643. You are given an integer array nums consisting...

Sliding Window Median Problem

LeetCode 480. The median is the middle value in an...

Permutation In String Problem

LeetCode 567. Given two strings s1 and s2, return true...

Find All Anagrams In A String Problem

LeetCode 438. Given two strings s and p, return an...

Sliding Window Maximum Problem

LeetCode 239. You are given an array of integersnums, there...

Minimum Size Subarray Sum Problem

LeetCode 209. Given an array of positive integers nums and...

Contains Duplicate III Problem

LeetCode 220. Given an integer array nums and two integers...

Contains Duplicate II Problem

LeetCode 219. Given an integer array nums and an integer...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...

Tag Sort

Merge Intervals Problem

LeetCode 56. Given an array of intervals, merge all overlapping...

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Tag Type Conversion

Implicit Type Conversions in C++

C++ transforms the operands to a common type before performing...

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...


Tag Cast

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...

Tag Template Specialization

Template Specializations in C++

A template specialization is a separate definition in which the...

Tag Partial Specialization

Template Specializations in C++

A template specialization is a separate definition in which the...

Tag Concurrency

Concurrency II: Introduction Cont'd

Another important question is how threads interact when they access...

Concurrency I: Introduction

A thread is an abstraction for a single running process....


Tag Thread

Concurrency II: Introduction Cont'd

Another important question is how threads interact when they access...

Concurrency I: Introduction

A thread is an abstraction for a single running process....

Tag C++ Concepts

C++ Concept List

A growing list of posts under the topic of C++...

Tag Object Oriented Design

Object Oriented Design Topic List

A growing list of posts under the topic of Object...

Tag Operating System

Operating System Topic List

A growing list of posts under the topic of Operating...


Tag Lambda Expression

Lambda Expressions in C++

A lambda expression is a convenient way of defining an...

Tag Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Tag Lvalue Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Tag Rvalue Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...


Tag LeetCode

LeetCode Database Solution List

A list of LeetCode database problems and solutions.

LeetCode Solution List

A growing list of LeetCode problems and solutions.

Tag MySQL

How To Specify Unique Constraint For Multiple Columns In MySQL

How to make multiple columns unique (together) in an existing...

How To Select One Row Per ID With Max Value On A Column

Suppose we have the following REIMBURSEMENT table, find the max...

How To Get The Size Of A Table In MySQL

How to get the size of a table in MySQL...

How To Get The Size Of A Database In MySQL

How to get the size of a database in MySQL...

How To Concatenate Multiple Rows Into One Field In MySQL

How to concatenate multiple rows into one field in MySQL...

How To Change The Data Type Of A Column In MySQL

Given a table EMPLOYEE, change the data type of the...

How To Set A Default Value For A MySQL Datetime Column

How to set a default value for a MySQL Datetime...

How To Output MySQL Query Results In CSV Format

This query writes results into a CSV file on the...

How To Get A List Of User Accounts In MySQL

MySQL stores the user information in its own database.

How To Find Duplicate Values In MySQL

Do a SELECT with a GROUP BY clause.

Users That Actively Request Confirmation Messages Problem

LeetCode 1939. Write an SQL query to find the IDs...

Strong Friendship Problem

LeetCode 1949. Write an SQL query to find all the...

Leetcodify Similar Friends Problem

LeetCode 1919. Write an SQL query to report the similar...

Leetcodify Friends Recommendations Problem

LeetCode 1917. Write an SQL query to recommend friends to...

First and Last Call On the Same Day Problem

LeetCode 1972. Write an SQL query to report the IDs...

Find Cutoff Score for Each School Problem

LeetCode 1988. Write an SQL query to report the minimum...

Employees With Missing Information Problem

LeetCode 1965. Write an SQL query to report the IDs...

Employees Whose Manager Left the Company Problem

LeetCode 1978. Write an SQL query to report the IDs...

Count the Number of Experiments Problem

LeetCode 1990. Write an SQL query to report the number...

Count Salary Categories Problem

LeetCode 1907. Write an SQL query to report the number...

Confirmation Rate Problem

LeetCode 1934. Write an SQL query to find the confirmation...

All the Pairs With the Maximum Number of Common Followers Problem

LeetCode 1951. Write an SQL query to find all the...

The Latest Login in 2020 Problem

LeetCode 1890. Write an SQL query to report the latest...

Suspicious Bank Accounts Problem

LeetCode 1843. Write an SQL query to report the IDs...

Page Recommendations II Problem

LeetCode 1892. Write an SQL query to find all the...

Orders With Maximum Quantity Above Average Problem

LeetCode 1867. Write an SQL query to find the order_id...

Maximum Transaction Each Day Problem

LeetCode 1831. Write an SQL query to report the IDs...

League Statistics Problem

LeetCode 1841. Write an SQL query to report the statistics...

Group Employees of the Same Salary Problem

LeetCode 1875. Write an SQL query to report the IDs...

Find Customers With Positive Revenue this Year Problem

LeetCode 1821. Write an SQL query to report the customers...

Convert Date Format Problem

LeetCode 1853. Write an SQL query to convert each date...

Calculate Special Bonus Problem

LeetCode 1873. Write an SQL query to calculate the bonus...

Rearrange Products Table Problem

LeetCode 1795. Write an SQL query to rearrange the Products...

Find Interview Candidates Problem

LeetCode 1811. Write an SQL query to report the name...

Ad-Free Sessions Problem

LeetCode 1809. Write an SQL query to report all the...

Primary Department For Each Employee Problem

LeetCode 1789. Write an SQL query to report all the...

Grand Slam Titles Problem

LeetCode 1783. Write an SQL query to report the number...

Product's Price For Each Store Problem

LeetCode 1777. Write an SQL query to find the price...

Find The Subtasks That Did Not Execute Problem

LeetCode 1767. Write an SQL query to report the IDs...

Recyclable And Low Fat Products Problem

LeetCode 1757. Write an SQL query to find the ids...

Leetflex Banned Accounts Problem

LeetCode 1747. Write an SQL query to find the account_id...

Find Total Time Spent By Each Employee Problem

LeetCode 1741. Write an SQL query to calculate the total...

The Number Of Employees Which Report To Each Employee Problem

LeetCode 1731. Write an SQL query to report the ids...

Find Followers Count Problem

LeetCode 1729. Write an SQL query that will, for each...

MySQL INNER JOIN Clause

The INNER JOIN keyword selects records that have matching values...

MySQL Aliases

Aliases are nicknames. They give us a shorthand way of...

Count Apples And Oranges Problem

LeetCode 1715. Write an SQL query to count the number...

MySQL OR Operator

The OR operator combines two Boolean expressions and returns true...

MySQL LIMIT Operator

The LIMIT clause is used in the SELECT statement to...

MySQL LIKE Operator

The LIKE operator is used in a WHERE clause to...

MySQL IS NULL Operator

To test whether a value is NULL or not, we...

MySQL IN Clause

The IN operator allows us to determine if a specified...

MySQL BETWEEN Operator

The BETWEEN operator selects values within a given range.

MySQL AND Operator

The AND operator is a logical operator that combines two...

MySQL WHERE Clause

The WHERE clause allows us to choose which rows are...

MySQL DISTINCT Clause

In order to remove duplicate rows, we use the DISTINCT...

Biggest Window Between Visits Problem

LeetCode 1709. Write an SQL query that will, for each...

MySQL ORDER BY Clause

The ORDER BY clause is used to sort the result-set...

MySQL SELECT Statement

The SELECT statement allows us to read data from one...

MySQL Tutorial List

A growing list of MySQL tutorials.

Total Sales Amount By Year Problem

LeetCode 1384. Write an SQL query to report the Total...

Sales By Day Of The Week Problem

LeetCode 1479. Write an SQL query to report how many...

Hopper Company Queries III Problem

LeetCode 1651. Write an SQL query to compute the average_ride_distance...

Get The Second Most Recent Activity Problem

LeetCode 1369. Write an SQL query to show the second...

Find The Quiet Students In All Exams Problem

LeetCode 1412. Write an SQL query to report the students...

Tournament Winners Problem

LeetCode 1194. Write an SQL query to find the winner...

Students Report By Geography Problem

LeetCode 618. A U.S graduate school has students from Asia,...

Report Contiguous Dates Problem

LeetCode 1225. Write an SQL query to generate a report...

Median Employee Salary Problem

LeetCode 569. Write a SQL query to find the median...

Market Analysis II Problem

LeetCode 1159. Write an SQL query to find for each...

Hopper Company Queries I Problem

LeetCode 1635. Write an SQL query to report the following...

Game Play Analysis V Problem

LeetCode 1097. Write an SQL query that reports for each...

User Purchase Platform Problem

LeetCode 1127. Write an SQL query to find the total...

Trips And Users Problem

LeetCode 262. Write a SQL query to find the cancellation...

Number Of Transactions Per Visit Problem

LeetCode 1336. Write an SQL query to find how many...

Human Traffic Of Stadium Problem

LeetCode 601. Write an SQL query to display the records...

Hopper Company Queries II Problem

LeetCode 1645. Write an SQL query to report the percentage...

Find Median Given Frequency Of Numbers Problem

LeetCode 571. Write a query to find the median of...

Find Cumulative Salary Of An Employee Problem

LeetCode 579. Write a SQL to get the cumulative sum...

Department Top Three Salaries Problem

LeetCode 185. Write a SQL query to find employees who...

Average Salary: Departments VS Company Problem

LeetCode 615. Given two tables as below, write a query...

Unpopular Books Problem

LeetCode 1098. Write an SQL query that reports the books...

Second Degree Follower Problem

LeetCode 614. Please write a sql query to get the...

Reported Posts II Problem

LeetCode 1132. Write an SQL query to find the average...

Number Of Calls Between Two Persons Problem

LeetCode 1699. Write an SQL query to report the number...

Nth Highest Salary Problem

LeetCode 177. Write a SQL query to get the nth...

New Users Daily Count Problem

LeetCode 1107. Write an SQL query that reports for every...

Monthly Transactions II Problem

LeetCode 1205. Write an SQL query to find for each...

Get Highest Answer Rate Question Problem

LeetCode 578. Write a sql query to identify the question...

Department Highest Salary Problem

LeetCode 184. Write a SQL query to find employees who...

Article Views II Problem

LeetCode 1149. Write an SQL query to find all the...

Active Users Problem

LeetCode 1454. Write an SQL query to find the id...

Winning Candidate Problem

LeetCode 574. Write a sql to find the name of...

Team Scores In Football Tournament Problem

LeetCode 1212. Write an SQL query that selects the team_id,...

Rank Scores Problem

LeetCode 178. Write a SQL query to rank scores. If...

Product Sales Analysis III Problem

LeetCode 1070. Write an SQL query that selects the product...

Movie Rating Problem

LeetCode 1341. Write the following SQL query to find the...

Investments In 2016 Problem

LeetCode 585. Write a query to print the sum of...

Immediate Food Delivery II Problem

LeetCode 1174. Write an SQL query to find the percentage...

Friend Requests II: Who Has The Most Friends Problem

LeetCode 602. In social network like Facebook or Twitter, people...

Countries You Can Safely Invest In Problem

LeetCode 1501. Write an SQL query to find the countries...

Count Student Number In Departments Problem

LeetCode 580. A university uses 2 data tables, student and...

Bank Account Summary Problem

LeetCode 1555. Our bank records all transactions in the table...

Tree Node Problem

LeetCode 608. Given a table tree, id is identifier of...

The Most Recent Orders For Each Product Problem

LeetCode 1549. Write an SQL query to find the most...

Shortest Distance In A Plane Problem

LeetCode 612. Write a query to find the shortest distance...

Rectangles Area Problem

LeetCode 1459. Write an SQL query to report of all...

Product Price At A Given Date Problem

LeetCode 1164. Write an SQL query to find the prices...

Page Recommendations Problem

LeetCode 1264. Write an SQL query to recommend pages to...

Monthly Transactions I Problem

LeetCode 1193. Write an SQL query to find for each...

Market Analysis I Problem

LeetCode 1158. Write an SQL query to find for each...

Managers With At Least 5 Direct Reports Problem

LeetCode 570. Given the Employee table, write a SQL query...

Find The Missing IDs Problem

LeetCode 1613. Write an SQL query to find the missing...

Exchange Seats Problem

LeetCode 626. Mary is a teacher in a middle school...

Customers Who Bought All Products Problem

LeetCode 1045. Write an SQL query for a report that...

Active Business Problem

LeetCode 1126. Write an SQL query to find all active...

The Most Recent Three Orders Problem

LeetCode 1532. Write an SQL query to find the most...

Restaurant Growth Problem

LeetCode 1321. You are the restaurant owner and you want...

Project Employees III Problem

LeetCode 1077. Write an SQL query that reports the most...

Number Of Trusted Contacts Of A Customer Problem

LeetCode 1364. Write an SQL query to find the following...

NPV Queries Problem

LeetCode 1421. Write an SQL query to find the npv...

Last Person To Fit In The Elevator Problem

LeetCode 1204. Write an SQL query to find the person_name...

Highest Grade For Each Student Problem

LeetCode 1112. Write a SQL query to find the highest...

Evaluate Boolean Expression Problem

LeetCode 1440. Write an SQL query to evaluate the boolean...

Calculate Salaries Problem

LeetCode 1468. Write an SQL query to find the salaries...

Activity Participants Problem

LeetCode 1355. Write an SQL query to find the names...

User Activity For The Past 30 Days II Problem

LeetCode 1142. Write an SQL query to find the average...

The Most Frequently Ordered Products For Each Customer Problem

LeetCode 1596. Write an SQL query to find the most...

Running Total For Different Genders Problem

LeetCode 1308. Write an SQL query to find the total...

Friendly Movies Streamed Last Month Problem

LeetCode 1495. Write an SQL query to report the distinct...

Friend Requests I: Overall Acceptance Rate Problem

LeetCode 597. Write an SQL query to find the overall...

Find The Start And End Number Of Continuous Ranges Problem

LeetCode 1285. Write an SQL query to find the start...

Customers Who Bought Products A And B But Not C Problem

LeetCode 1398. Write an SQL query to report the customer_id...

Classes More Than 5 Students Problem

LeetCode 596. Please list out all classes which have more...

Capital Gain/Loss Problem

LeetCode 1393. Write an SQL query to report the Capital...

Biggest Single Number Problem

LeetCode 619. Table my_numbers contains many numbers in column num...

Apples & Oranges Problem

LeetCode 1445. Write an SQL query to report the difference...

All People Report To The Given Manager Problem

LeetCode 1270. Write an SQL query to find employee_id of...

Weather Type In Each Country Problem

LeetCode 1294. Write an SQL query to find the type...

User Activity For The Past 30 Days I Problem

LeetCode 1141. Write an SQL query to find the daily...

Triangle Judgement Problem

LeetCode 610. A pupil Tim gets homework to identify whether...

Students And Examinations Problem

LeetCode 1280. Write an SQL query to find the number...

Sales Person Problem

LeetCode 607. Given three tables, salesperson, company, orders.

Sales Analysis III Problem

LeetCode 1084. Write an SQL query that reports the products...

Sales Analysis II Problem

LeetCode 1083. Write an SQL query that reports the buyers...

Reported Posts Problem

LeetCode 1113. Write an SQL query that reports the number...

Queries Quality And Percentage Problem

LeetCode 1211. Write an SQL query to find each query_name,...

Project Employees II Problem

LeetCode 1076. Write an SQL query that reports all the...

Project Employees I Problem

LeetCode 1075. Write an SQL query that reports the average...

Number Of Comments Per Post Problem

LeetCode 1241. Write an SQL query to find number of...

Not Boring Movies Problem

LeetCode 620. X city opened a new cinema, many people...

Fix Product Name Format Problem

LeetCode 1543. Write an SQL query to report product_name in...

Consecutive Available Seats Problem

LeetCode 603. Several friends at a cinema ticket office would...

Ads Performance Problem

LeetCode 1322. A company is running Ads and wants to...

Top Travellers Problem

LeetCode 1407. Write an SQL query to report the distance...

Swap Salary Problem

LeetCode 627. Given a table salary, such as the one...

Shortest Distance Problem

LeetCode 613. Write a query to find the shortest distance...

Sales Analysis I Problem

LeetCode 1082. Write an SQL query that reports the best...

Reformat Department Table Problem

LeetCode 1179. Write an SQL query to reformat the table...

Product Sales Analysis II Problem

LeetCode 1069. Write an SQL query that reports the total...

Product Sales Analysis I Problem

LeetCode 1068. Write an SQL query that reports all product...

List The Products Ordered In A Period Problem

LeetCode 1327. Write an SQL query to get the names...

Immediate Food Delivery I Problem

LeetCode 1173. Write an SQL query to find the percentage...

Find Users With Valid Emails Problem

LeetCode 1517. Write an SQL query to find the users...

Find Customer Referee Problem

LeetCode 584. Given a table customer holding customers information and...

Customer Placing The Largest Number Of Orders Problem

LeetCode 586. Query the customer_number from the orders table for...

Customer Order Frequency Problem

LeetCode 1511. Write an SQL query to report the customer_id...

Create A Session Bar Chart Problem

LeetCode 1435. You want to know how long a user...

Big Countries Problem

LeetCode 595. Write a SQL solution to output big countries’...

Average Selling Price Problem

LeetCode 1251. Write an SQL query to find the average...

Article Views I Problem

LeetCode 1148. Write an SQL query to find all the...

Actors And Directors Who Cooperated At Least Three Times Problem

LeetCode 1050. Write a SQL query for a report that...

Unique Orders And Customers Per Month Problem

LeetCode 1565. Write an SQL query to find the number...

Sellers With No Sales Problem

LeetCode 1607. Write an SQL query to report the names...

Rising Temperature Problem

LeetCode 197. Write an SQL query to find all dates’...

Game Play Analysis IV Problem

LeetCode 550. Write an SQL query that reports the fraction...

Game Play Analysis III Problem

LeetCode 534. Write an SQL query that reports for each...

Game Play Analysis II Problem

LeetCode 512. Write a SQL query that reports the device...

Game Play Analysis I Problem

LeetCode 511. Write an SQL query that reports the first...

Employee Bonus Problem

LeetCode 577. Select all employee’s name and bonus whose bonus...

Delete Duplicate Emails Problem

LeetCode 196. Write a SQL query to delete all duplicate...

Daily Leads And Partners Problem

LeetCode 1693. Write an SQL query that will, for each...

Customer Who Visited But Did Not Make Any Transactions Problem

LeetCode 1581. Write an SQL query to find the IDs...

Product's Worth Over Invoices Problem

LeetCode 1677. Write an SQL query that will, for all...

Percentage Of Users Attended A Contest Problem

LeetCode 1633. Write an SQL query to find the percentage...

Fix Names In A Table Problem

LeetCode 1667. Write an SQL query to fix the names...

Duplicate Emails Problem

LeetCode 182. Write a SQL query to find all duplicate...

Customers Who Never Order Problem

LeetCode 183. Write a SQL query to find all customers...

Consecutive Numbers Problem

LeetCode 180. Write an SQL query to find all numbers...

Average Time Of Process Per Machine Problem

LeetCode 1661. There is a factory website that has several...

Second Highest Salary Problem

LeetCode 176. Given the Employee table, write a SQL query...

Employees Earning More Than Their Managers Problem

LeetCode 181. Given the Employee table, write a SQL query...

Bank Account Summary II Problem

LeetCode 1587. Write an SQL query to report the name...

Group Sold Products By The Date Problem

LeetCode 1484. Write an SQL query to find for each...

All Valid Triplets That Can Represent A Country Problem

LeetCode 1623. Write an SQL query to find all the...

Warehouse Manager Problem

LeetCode 1571. Write an SQL query to report how much...

Students With Invalid Departments Problem

LeetCode 1350. Write an SQL query to find the id...

Replace Employee ID With The Unique Identifier Problem

LeetCode 1378. Write an SQL query to show the unique...

Patients With A Condition Problem

LeetCode 1527. Write an SQL query to report the patient_id,...

Invalid Tweets Problem

LeetCode 1683. Write an SQL query to find the IDs...

Find The Team Size Problem

LeetCode 1303. Write an SQL query to find the team...

Combine Two Tables Problem

LeetCode 175. Write a SQL query for a report that...

Tag Database

How To Specify Unique Constraint For Multiple Columns In MySQL

How to make multiple columns unique (together) in an existing...

How To Select One Row Per ID With Max Value On A Column

Suppose we have the following REIMBURSEMENT table, find the max...

How To Get The Size Of A Table In MySQL

How to get the size of a table in MySQL...

How To Get The Size Of A Database In MySQL

How to get the size of a database in MySQL...

How To Concatenate Multiple Rows Into One Field In MySQL

How to concatenate multiple rows into one field in MySQL...

How To Change The Data Type Of A Column In MySQL

Given a table EMPLOYEE, change the data type of the...

How To Set A Default Value For A MySQL Datetime Column

How to set a default value for a MySQL Datetime...

How To Output MySQL Query Results In CSV Format

This query writes results into a CSV file on the...

How To Get A List Of User Accounts In MySQL

MySQL stores the user information in its own database.

How To Find Duplicate Values In MySQL

Do a SELECT with a GROUP BY clause.

MySQL INNER JOIN Clause

The INNER JOIN keyword selects records that have matching values...

MySQL Aliases

Aliases are nicknames. They give us a shorthand way of...

MySQL OR Operator

The OR operator combines two Boolean expressions and returns true...

MySQL LIMIT Operator

The LIMIT clause is used in the SELECT statement to...

MySQL LIKE Operator

The LIKE operator is used in a WHERE clause to...

MySQL IS NULL Operator

To test whether a value is NULL or not, we...

MySQL IN Clause

The IN operator allows us to determine if a specified...

MySQL BETWEEN Operator

The BETWEEN operator selects values within a given range.

MySQL AND Operator

The AND operator is a logical operator that combines two...

MySQL WHERE Clause

The WHERE clause allows us to choose which rows are...

MySQL DISTINCT Clause

In order to remove duplicate rows, we use the DISTINCT...

MySQL ORDER BY Clause

The ORDER BY clause is used to sort the result-set...

MySQL SELECT Statement

The SELECT statement allows us to read data from one...

MySQL Tutorial List

A growing list of MySQL tutorials.

Tag Query

How To Specify Unique Constraint For Multiple Columns In MySQL

How to make multiple columns unique (together) in an existing...

How To Select One Row Per ID With Max Value On A Column

Suppose we have the following REIMBURSEMENT table, find the max...

How To Get The Size Of A Table In MySQL

How to get the size of a table in MySQL...

How To Get The Size Of A Database In MySQL

How to get the size of a database in MySQL...

How To Concatenate Multiple Rows Into One Field In MySQL

How to concatenate multiple rows into one field in MySQL...

How To Change The Data Type Of A Column In MySQL

Given a table EMPLOYEE, change the data type of the...

How To Set A Default Value For A MySQL Datetime Column

How to set a default value for a MySQL Datetime...

How To Output MySQL Query Results In CSV Format

This query writes results into a CSV file on the...

How To Get A List Of User Accounts In MySQL

MySQL stores the user information in its own database.

How To Find Duplicate Values In MySQL

Do a SELECT with a GROUP BY clause.

MySQL INNER JOIN Clause

The INNER JOIN keyword selects records that have matching values...

MySQL Aliases

Aliases are nicknames. They give us a shorthand way of...

MySQL OR Operator

The OR operator combines two Boolean expressions and returns true...

MySQL LIMIT Operator

The LIMIT clause is used in the SELECT statement to...

MySQL LIKE Operator

The LIKE operator is used in a WHERE clause to...

MySQL IS NULL Operator

To test whether a value is NULL or not, we...

MySQL IN Clause

The IN operator allows us to determine if a specified...

MySQL BETWEEN Operator

The BETWEEN operator selects values within a given range.

MySQL AND Operator

The AND operator is a logical operator that combines two...

MySQL WHERE Clause

The WHERE clause allows us to choose which rows are...

MySQL DISTINCT Clause

In order to remove duplicate rows, we use the DISTINCT...

MySQL ORDER BY Clause

The ORDER BY clause is used to sort the result-set...

MySQL SELECT Statement

The SELECT statement allows us to read data from one...


Tag String

Word Subsets Problem

LeetCode 916. You are given two string arrays words1 and...

Vowel Spellchecker Problem

LeetCode 966. Given a wordlist, we want to implement a...

Verifying An Alien Dictionary Problem

LeetCode 953. In an alien language, surprisingly, they also use...

Unique Morse Code Words Problem

LeetCode 804. International Morse Code defines a standard encoding where...

Unique Email Addresses Problem

LeetCode 929. Every valid email consists of a local name...

Uncommon Words From Two Sentences Problem

LeetCode 884. A sentence is a string of single-space separated...

Time Based Key-Value Store Problem

LeetCode 981. Design a time-based key-value data structure that can...

Subdomain Visit Count Problem

LeetCode 811. A website domain “discuss.leetcode.com” consists of various subdomains....

String Without Aaa Or Bbb Problem

LeetCode 984. Given two integers a and b, return any...

Stamping The Sequence Problem

LeetCode 936. You are given two strings stamp and target....

Split Array Into Fibonacci Sequence Problem

LeetCode 842. You are given a string of digits num,...

Smallest String Starting From Leaf Problem

LeetCode 988. You are given the root of a binary...

Similar String Groups Problem

LeetCode 839. Two strings Xand Yare similar if we can...

Shortest Distance To A Character Problem

LeetCode 821. Given a string s and a character c...

Short Encoding Of Words Problem

LeetCode 820. A valid encoding of an array of words...

Shifting Letters Problem

LeetCode 848. You are given a string s of lowercase...

Score Of Parentheses Problem

LeetCode 856. Given a balanced parentheses string s, return the...

Satisfiability Of Equality Equations Problem

LeetCode 990. You are given an array of strings equations...

Reverse Only Letters Problem

LeetCode 917. Given a string s, reverse the string according...

Reorder Data In Log Files Problem

LeetCode 937. You are given an array of logs. Each...

Push Dominoes Problem

LeetCode 838. There are n dominoes in a line, and...

Positions Of Large Groups Problem

LeetCode 830. In a string sof lowercase letters, these letters...

Orderly Queue Problem

LeetCode 899. You are given a string s and an...

Numbers At Most N Given Digit Set Problem

LeetCode 902. Given an array of digits which is sorted...

Number Of Lines To Write String Problem

LeetCode 806. You are given a string s of lowercase...

Most Common Word Problem

LeetCode 819. Given a string paragraph and a string array...

Minimum Add To Make Parentheses Valid Problem

LeetCode 921. A parentheses string is valid if and only...

Masking Personal Information Problem

LeetCode 831. You are given a personal information string s,...

Long Pressed Name Problem

LeetCode 925. Your friend is typing his name into a...

Largest Time For Given Digits Problem

LeetCode 949. Given an arrayarr of 4 digits, find the...

K-Similar Strings Problem

LeetCode 854. Strings s1 and s2 are k-similar (for some...

Guess The Word Problem

LeetCode 843. This is an interactive problem.

Groups Of Special-Equivalent Strings Problem

LeetCode 893. You are given an array of strings of...

Goat Latin Problem

LeetCode 824. You are given a string sentence that consist...

Flip String To Monotone Increasing Problem

LeetCode 926. A binary string is monotone increasing if it...

Find The Shortest Superstring Problem

LeetCode 943. Given an array of strings words, return the...

Find And Replace Pattern Problem

LeetCode 890. Given a list of strings words and a...

Find And Replace In String Problem

LeetCode 833. You are given a 0-indexed string s that...

Expressive Words Problem

LeetCode 809. Sometimes people repeat letters to represent extra feeling....

Equal Rational Numbers Problem

LeetCode 972. Given two strings s and t, each of...

Distinct Subsequences II Problem

LeetCode 940. Given a string s, return the number of...

DI String Match Problem

LeetCode 942. A permutation perm of n + 1 integers...

Delete Columns To Make Sorted Problem

LeetCode 944. You are given an array of n strings...

Delete Columns To Make Sorted III Problem

LeetCode 960. You are given an array of n strings...

Delete Columns To Make Sorted II Problem

LeetCode 955. You are given an array of n strings...

Decoded String At Index Problem

LeetCode 880. You are given an encoded string s. To...

Count Unique Characters Of All Substrings Of A Given String Problem

LeetCode 828. Let’s define a function countUniqueChars(s) that returns the...

Buddy Strings Problem

LeetCode 859. Given two strings s and goal, return true...

Backspace String Compare Problem

LeetCode 844. Given two strings s and t, return true...

Ambiguous Coordinates Problem

LeetCode 816. We had some 2-dimensional coordinates, like “(1, 3)”...

Valid Tic-Tac-Toe State Problem

LeetCode 794. Given a Tic-Tac-Toe board as a string array...

Valid Parenthesis String Problem

LeetCode 678. Given a string s containing only three types...

Valid Palindrome II Problem

LeetCode 680. Given a string s, return true if the...

Top K Frequent Words Problem

LeetCode 692. Given an array of strings words and an...

Swap Adjacent In LR String Problem

LeetCode 777. In a string composed of ‘L’, ‘R’, and...

Strange Printer Problem

LeetCode 664. There is a strange printer with the following...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Special Binary String Problem

LeetCode 761. Special binary strings are binary strings with the...

Solve The Equation Problem

LeetCode 640. Solve a given equation and return the value...

Robot Return To Origin Problem

LeetCode 657. There is a robot starting at the position...

Reorganize String Problem

LeetCode 767. Given a string s, rearrange the characters of...

Partition Labels Problem

LeetCode 763. You are given a string s. We want...

Parse Lisp Expression Problem

LeetCode 736. You are given a string expression representing a...

Open The Lock Problem

LeetCode 752. You have a lock in front of you...

Dota2 Senate Problem

LeetCode 649. In the world of Dota2, there are two...

To Lower Case Problem

LeetCode 709. Given a string s, return the string after...

Shortest Completing Word Problem

LeetCode 748. Given a string licensePlate and an array of...

Rotate String Problem

LeetCode 796. Given two strings s and goal, return true...

Repeated String Match Problem

LeetCode 686. Given two string s a and b, return...

Remove Comments Problem

LeetCode 722. Given a C++ program, remove comments from it....

Prefix And Suffix Search Problem

LeetCode 745. Design a special dictionary with some words that...

Number Of Matching Subsequences Problem

LeetCode 792. Given a string s and an array of...

Number Of Atoms Problem

LeetCode 726. Given a string formula representing a chemical formula,return...

Minimum Ascii Delete Sum For Two Strings Problem

LeetCode 712. Given two strings s1 ands2, return the lowest...

Letter Case Permutation Problem

LeetCode 784. Given a string s, we can transform every...

Find Duplicate File In System Problem

LeetCode 609. Given a list paths of directory info, including...

Palindromic Substrings Problem

LeetCode 647. Given a string s, return the number of...

Map Sum Pairs Problem

LeetCode 677. Design a map that allows you to do...

Implement Magic Dictionary Problem

LeetCode 676. Design a data structure that is initialized with...

Decode Ways II Problem

LeetCode 639. A message containing letters from A-Z can be...

Custom Sort String Problem

LeetCode 791. You are given two strings order and s....

Count Binary Substrings Problem

LeetCode 696. Give a binary string s, return the number...

Construct String From Binary Tree Problem

LeetCode 606. Given the root of a binary tree, construct...

Basic Calculator IV Problem

LeetCode 770. Given an expression such as expression = “e...

Accounts Merge Problem

LeetCode 721. Given a list of accounts where each element...

Zuma Game Problem

LeetCode 488. You are playing a variation of the game...

Validate IP Address Problem

LeetCode 468. Given a string queryIP, return “IPv4” if IP...

Tag Validator Problem

LeetCode 591. Given a string representing a code snippet, implement...

Strong Password Checker Problem

LeetCode 420. A password is considered strong if the below...

Freedom Trail Problem

LeetCode 514. In the video game Fallout 4, the quest...

Find The Closest Palindrome Problem

LeetCode 564. Given a string n representing an integer, return...

Student Attendance Record I Problem

LeetCode 551. You are given a string s representing an...

String Compression Problem

LeetCode 443. Given an array of characters chars, compress it...

Sort Characters By Frequency Problem

LeetCode 451. Given a string s, sort it in decreasing...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Reverse Words In A String III Problem

LeetCode 557. Given a string s, reverse the order of...

Reverse String II Problem

LeetCode 541. Given a string s and an integer k,...

Repeated Substring Pattern Problem

LeetCode 459. Given a string s, check if it can...

Remove K Digits Problem

LeetCode 402. Given string num representing a non-negative integer num,...

Reconstruct Original Digits From English Problem

LeetCode 423. Given a string s containing an out-of-order English...

Permutation In String Problem

LeetCode 567. Given two strings s1 and s2, return true...

Ones And Zeroes Problem

LeetCode 474. You are given an array of binary strings...

Number Of Segments In A String Problem

LeetCode 434. You are given a string s, return the...

Next Greater Element III Problem

LeetCode 556. Given a positive integer n, find the smallest...

Minimum Time Difference Problem

LeetCode 539. Given a list of 24-hour clock time points...

Minimum Genetic Mutation Problem

LeetCode 433. A gene string can be represented by an...

Minimum Index Sum Of Two Lists Problem

LeetCode 599. Suppose Andy and Doris want to choose a...

Magical String Problem

LeetCode 481. A magical string s consists of only ‘1’...

Longest Uncommon Subsequence II Problem

LeetCode 522. Given an array of strings strs, return the...

Longest Uncommon Subsequence I Problem

LeetCode 521. Given two strings a and b, return the...

Longest Palindromic Subsequence Problem

LeetCode 516. Given a string s, find the longest palindromic...

Longest Palindrome Problem

LeetCode 409. Given a string s which consists of lowercase...

License Key Formatting Problem

LeetCode 482. You are given a license key represented as...

Keyboard Row Problem

LeetCode 500. Given an array of strings words, return the...

Fraction Addition And Subtraction Problem

LeetCode 592. Given a string expression representing an expression of...

Find All Anagrams In A String Problem

LeetCode 438. Given two strings s and p, return an...

Encode And Decode TinyURL Problem

LeetCode 535. TinyURL is a URL shortening service where you...

Detect Capital Problem

LeetCode 520. We define the usage of capitals in a...

Delete Operation For Two Strings Problem

LeetCode 583. Given two strings word1 and word2, return the...

Complex Number Multiplication Problem

LeetCode 537. A complex number can be represented as a...

Fizz Buzz Problem

LeetCode 412. Given an integer n, return a string array...

Add Strings Problem

LeetCode 415. Given two non-negative integers, num1 and num2 represented...

Verify Preorder Serialization Of A Binary Tree Problem

LeetCode 331. One way to serialize a binary tree is...

Valid Anagram Problem

LeetCode 242. Given two strings s and t, return true...

Shortest Palindrome Problem

LeetCode 214. You are given a string s. You can...

Serialize And Deserialize Binary Tree Problem

LeetCode 297. Serialization is the process of converting a data...

Reverse Vowels Of A String Problem

LeetCode 345. Given a string s, reverse only all the...

Reverse String Problem

LeetCode 344. Write a function that reverses a string. The...

Remove Invalid Parentheses Problem

LeetCode 301. Given a string s that contains parentheses and...

Remove Duplicate Letters Problem

LeetCode 316. Given a string s, remove duplicate letters so...

Word Pattern Problem

LeetCode 290. Given a pattern and a string s, find...

Ransom Note Problem

LeetCode 383. Given two stings ransomNote and magazine, return true...

Palindrome Pairs Problem

LeetCode 336. Given a list of unique words, return all...

Mini Parser Problem

LeetCode 385. Given a string s represents the serialization of...

Maximum Product Of Word Lengths Problem

LeetCode 318. Given a string array words, return the maximum...

Longest Absolute File Path Problem

LeetCode 388. Suppose we have a file system that stores...

Isomorphic Strings Problem

LeetCode 205. Given two strings s and t, determine if...

Is Subsequence Problem

LeetCode 392. Given two strings s and t, return true...

Integer To English Words Problem

LeetCode 273. Convert a non-negative integer num to its English...

First Unique Character In A String Problem

LeetCode 387. Given a string s, find the first non-repeating...

Find The Difference Problem

LeetCode 389. You are given two strings s and t....

Expression Add Operators Problem

LeetCode 282. Given a string num that contains only digits...

Different Ways To Add Parentheses Problem

LeetCode 241. Given a string expression of numbers and operators,...

Design Add And Search Words Data Structure Problem

LeetCode 211. Design a data structure that supports adding new...

Decode String Problem

LeetCode 394. Given an encoded string, return its decoded string....

Bulls And Cows Problem

LeetCode 299. You are playing the Bulls and Cows game...

Binary Tree Paths Problem

LeetCode 257. Given the root of a binary tree, return...

Basic Calculator Problem

LeetCode 224. Given a string s representing a valid expression,...

Basic Calculator II Problem

LeetCode 227. Given a string s which represents an expression,...

Additive Number Problem

LeetCode 306. Additive number is a string whose digits can...

Reverse Words In A String Problem

LeetCode 151. Given an input string s, reverse the order...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...

Largest Number Problem

LeetCode 179. Given a list of non-negative integers nums, arrange...

Fraction To Recurring Decimal Problem

LeetCode 166. Given two integers representing the numerator and denominator...

Excel Sheet Column Title Problem

LeetCode 168. Given an integer columnNumber, return its corresponding column...

Excel Sheet Column Number Problem

LeetCode 171. Given a string columnTitle that represents the column...

Compare Version Numbers Problem

LeetCode 165. Given two version numbers,version1 and version2, compare them....

Word Break Problem

LeetCode 139. Given a string s and a dictionary of...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Palindrome Partitioning Problem

LeetCode 131. Given a string s, partition s such that...

Palindrome Partitioning II Problem

LeetCode 132. Given a string s, partition s such that...

Word Ladder Problem

LeetCode 127. Given two words, beginWord and endWord, and a...

Word Ladder II Problem

LeetCode 126. Given two words, beginWord and endWord, and a...

Valid Palindrome Problem

LeetCode 125. A phrase is a palindrome if, after converting...

Distinct Subsequences Problem

LeetCode 115. Given two strings s and t, return the...

Interleaving String Problem

LeetCode 97. Given strings s1, s2, and s3, find whether...

Scramble String Problem

LeetCode 87. Given two strings s1 and s2 of the...

Restore IP Addresses Problem

LeetCode 93. Given a string s containing only digits, return...

Decode Ways Problem

LeetCode 91. Given a string s containing only digits, return...

Simplify Path Problem

LeetCode 71. Given a string path, which is an absolute...

Edit Distance Problem

LeetCode 72. Given two strings word1 and word2, return the...

Valid Number Problem

LeetCode 65. Given a string s, return true if s...

Text Justification Problem

LeetCode 68. Given an array of strings words and a...

Valid Number Problem

LeetCode 67. A robot is located at the top-left corner...

Length Of Last Word Problem

LeetCode 58. Given a string s consisting of some words...

Zigzag Conversion Problem

LeetCode 6. Write the code that will take a string...

Wildcard Matching Problem

LeetCode 44. Write the code that will take a string...

Regular Expression Matching Problem

LeetCode 10. Given an input string s and a pattern...

Multiply Strings Problem

LeetCode 43. Given two non-negative integers num1 and num2 represented...

Longest Valid Parentheses Problem

LeetCode 32. Given a string containing just the characters ‘(‘...

Integer to Roman Problem

LeetCode 12. Given an integer, convert it to a roman...

Group Anagrams Problem

LeetCode 49. Given an array of strings strs, group the...

Count and Say Problem

LeetCode 38. Write the code that will take a string...

Valid Parentheses Problem

LeetCode 20. Given a string s containing just the characters...

Roman to Integer Problem

LeetCode 13. Given a roman numeral, convert it to an...

Longest Common Prefix Problem

LeetCode 14. Write a function to find the longest common...

Letter Combinations of a Phone Number Problem

LeetCode 17. Given a string containing digits from 2-9 inclusive,...

Generate Parentheses Problem

LeetCode 22. Given n pairs of parentheses, write a function...

Determine Color Of A Chessboard Square Problem

LeetCode 1812. You are given coordinates, a string that represents...

String To Interger (atoi) Problem

LeetCode 8. Implement the myAtoi(string s) function, which converts a...

Tag Reverse

Reverse Prefix of Word Problem

LeetCode 2000. Given a 0-indexed string word and a character...

Tag DFS

Smallest Greater Multiple Made of Two Digits Problem

LeetCode 1999. Given three integers, k, digit1, and digit2, you...

Tag Git Reset

How to Undo a Git Add Before Commit

Short answers to the question how to undo a git...

How to Undo the Most Recent Local Commit in Git

Short answers to the question how to undo the most...


Tag Git Branch

How to Rename a Local Git Branch

Short answers to the question how to rename a local...

How to Delete a Git Branch Locally and Remotely

Short answers to the question how to delete a git...

How to Checkout a Remote Git Branch

Short answers to the question how to checkout a remote...

Tag Git

Git Short Answers List

A growing list of Git questions and short answers.

Tag Two Pointers

Squares Of A Sorted Array Problem

LeetCode 977. Given an integer array nums sorted in non-decreasing...

Sort Array By Parity Problem

LeetCode 905. Given an integer array nums, move all the...

Sort Array By Parity II Problem

LeetCode 922. Given an array of integers nums, half of...

Shortest Distance To A Character Problem

LeetCode 821. Given a string s and a character c...

Reverse Only Letters Problem

LeetCode 917. Given a string s, reverse the string according...

Push Dominoes Problem

LeetCode 838. There are n dominoes in a line, and...

Pancake Sorting Problem

LeetCode 969. Given an array of integers arr, sort the...

Most Profit Assigning Work Problem

LeetCode 826. You have n jobs and m workers. You...

Middle Of The Linked List Problem

LeetCode 876. Given the head of a singly linked list,...

Longest Mountain In Array Problem

LeetCode 845. Given an integer array arr, return the length...

Long Pressed Name Problem

LeetCode 925. Your friend is typing his name into a...

Interval List Intersections Problem

LeetCode 986. You are given two lists of closed intervals,...

Friends Of Appropriate Ages Problem

LeetCode 825. There are n persons on a social media...

Flipping An Image Problem

LeetCode 832. Given an n x n binary matrix image,...

Expressive Words Problem

LeetCode 809. Sometimes people repeat letters to represent extra feeling....

DI String Match Problem

LeetCode 942. A permutation perm of n + 1 integers...

Boats To Save People Problem

LeetCode 881. You are given an array people where people[i]...

Bag Of Tokens Problem

LeetCode 948. You have an initial power of power, an...

Backspace String Compare Problem

LeetCode 844. Given two strings s and t, return true...

Advantage Shuffle Problem

LeetCode 870. You are given two integer arrays nums1 and...

3Sum With Multiplicity Problem

LeetCode 923. Given an integer array arr, and an integer...

Valid Triangle Number Problem

LeetCode 611. Given an integer array nums, return the number...

Valid Palindrome II Problem

LeetCode 680. Given a string s, return true if the...

Swap Adjacent In LR String Problem

LeetCode 777. In a string composed of ‘L’, ‘R’, and...

Partition Labels Problem

LeetCode 763. You are given a string s. We want...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Sum Of Square Numbers Problem

LeetCode 633. Given a non-negative integer c, decide whether there’re...

Number Of Subarrays With Bounded Maximum Problem

LeetCode 795. Given an integer array nums and two integers...

Find K-Th Smallest Pair Distance Problem

LeetCode 719. The distance of a pair of integers a...

Find K Closest Elements Problem

LeetCode 658. Given a sorted integer array arr, two integers...

Count Binary Substrings Problem

LeetCode 696. Give a binary string s, return the number...

String Compression Problem

LeetCode 443. Given an array of characters chars, compress it...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Reverse Words In A String III Problem

LeetCode 557. Given a string s, reverse the order of...

Reverse String II Problem

LeetCode 541. Given a string s and an integer k,...

Permutation In String Problem

LeetCode 567. Given two strings s1 and s2, return true...

Next Greater Element III Problem

LeetCode 556. Given a positive integer n, find the smallest...

Magical String Problem

LeetCode 481. A magical string s consists of only ‘1’...

Longest Uncommon Subsequence II Problem

LeetCode 522. Given an array of strings strs, return the...

K-Diff Pairs In An Array Problem

LeetCode 532. Given an array of integers nums and an...

Heaters Problem

LeetCode 475. Winter is coming! During the contest, your first...

Circular Array Loop Problem

LeetCode 457. You are playing a game involving a circular...

Assign Cookies Problem

LeetCode 455. Assume you are an awesome parent and want...

Reverse Vowels Of A String Problem

LeetCode 345. Given a string s, reverse only all the...

Reverse String Problem

LeetCode 344. Write a function that reverses a string. The...

Move Zeroes Problem

LeetCode 283. Given an integer array nums, move all 0’s...

Is Subsequence Problem

LeetCode 392. Given two strings s and t, return true...

Intersection Of Two Arrays II Problem

LeetCode 350. Given two integer arrays nums1 and nums2, return...

Happy Number Problem

LeetCode 202. Write an algorithm to determine if a number...

Find The Duplicate Number Problem

LeetCode 287. Given an array of integers nums containingn +...

Find Median From Data Stream Problem

LeetCode 295. The median is the middle value in an...

Rotate Array Problem

LeetCode 189. Given an array, rotate the array to the...

Reverse Words In A String Problem

LeetCode 151. Given an input string s, reverse the order...

Intersection Of Two Linked Lists Problem

LeetCode 160. Given the heads of two singly linked-lists headA...

Compare Version Numbers Problem

LeetCode 165. Given two version numbers,version1 and version2, compare them....

Sort List Problem

LeetCode 148. Given the head of a linked list, return...

Reorder List Problem

LeetCode 143. You are given the head of a singly...

Linked List Cycle Problem

LeetCode 141. Given head, the head of a linked list,...

Linked List Cycle II Problem

LeetCode 142. Given the head of a linked list, return...

Valid Palindrome Problem

LeetCode 125. A phrase is a palindrome if, after converting...

Remove Duplicates from Sorted List II Problem

LeetCode 82. Given the head of a sorted linked list,...

Remove Duplicates from Sorted Array II Problem

LeetCode 80. Given an integer array nums sorted in non-decreasing...

Partition List Problem

LeetCode 86. Given the head of a linked list and...

Merge Sorted Array Problem

LeetCode 88. You are given two integer arrays nums1 and...

Sort Colors Problem

LeetCode 75. Given an array nums with n objects colored...

Rotate List Problem

LeetCode 61. Given the head of a linked list, rotate...

Trapping Rain Water Problem

LeetCode 42. Given n non-negative integers representing an elevation map...

Search in Rotated Sorted Array Problem

LeetCode 33. Given the array nums after the possible rotation...

Remove Element Problem

LeetCode 27. Given an integer array nums and an integer...

Next Permutation Problem

LeetCode 31. Implement next permutation, which rearranges numbers into the...

3Sum Closest Problem

LeetCode 16. Given an integer array nums of length n...

Remove Nth Node From End of List Problem

LeetCode 19. Given the head of a linked list, remove...

Remove Duplicates from Sorted Array Problem

LeetCode 26. Given an integer array nums sorted in non-decreasing...

Container With Most Water Problem

LeetCode 11. Given n non-negative integers a_1, a_2, …, a_n...

Tag BST

Depth of BST Given Insertion Order Problem

LeetCode 1902. You are given a 0-indexed integer array order...


Tag Dynamic Programming

Valid Permutations For DI Sequence Problem

LeetCode 903. You are given a string s of length...

Tallest Billboard Problem

LeetCode 956. You are installing a billboard and want it...

Super Egg Drop Problem

LeetCode 887. You are given k identical eggs and you...

Sum Of Subarray Minimums Problem

LeetCode 907. Given an array of integers arr, find the...

Sum Of Distances In Tree Problem

LeetCode 834. There is an undirected connected tree with n...

Stone Game Problem

LeetCode 877. Alice and Bob play a game with piles...

Split Array With Same Average Problem

LeetCode 805. You are given an integer array nums.

Soup Servings Problem

LeetCode 808. There are two types of soup, type A...

Shortest Path Visiting All Nodes Problem

LeetCode 847. You have an undirected, connected graph of n...

Race Car Problem

LeetCode 818. Your car starts at position 0 and speed...

Push Dominoes Problem

LeetCode 838. There are n dominoes in a line, and...

Profitable Schemes Problem

LeetCode 879. There is a group of n members, and...

Odd Even Jump Problem

LeetCode 975. You are given an integer array arr. From...

Numbers At Most N Given Digit Set Problem

LeetCode 902. Given an array of digits which is sorted...

Number Of Squareful Arrays Problem

LeetCode 996. An array is squareful if the sum of...

Number Of Music Playlists Problem

LeetCode 920. Your music player contains n different songs. You...

New 21 Game Problem

LeetCode 837. Alice plays the following game, loosely based on...

Minimum Number Of Refueling Stops Problem

LeetCode 871. A car travels from a starting position to...

Minimum Falling Path Sum Problem

LeetCode 931. Given an n x n array of integers...

Minimum Cost To Merge Stones Problem

LeetCode 1000. There are n piles of stones arranged in...

Minimum Cost For Tickets Problem

LeetCode 983. You have planned some train traveling one year...

Maximum Sum Circular Subarray Problem

LeetCode 918. Given a circular integer array nums of length...

Longest Turbulent Subarray Problem

LeetCode 978. Given an integer array arr, return the length...

Longest Mountain In Array Problem

LeetCode 845. Given an integer array arr, return the length...

Length Of Longest Fibonacci Subsequence Problem

LeetCode 873. Given a strictly increasing array arr of positive...

Least Operators To Express Number Problem

LeetCode 964. Given a single positive integer x, we will...

Largest Sum Of Averages Problem

LeetCode 813. You are given an integer array nums and...

Knight Dialer Problem

LeetCode 935. The chess knight has a unique movement, it...

Flip String To Monotone Increasing Problem

LeetCode 926. A binary string is monotone increasing if it...

Find The Shortest Superstring Problem

LeetCode 943. Given an array of strings words, return the...

Distinct Subsequences II Problem

LeetCode 940. Given a string s, return the number of...

Delete Columns To Make Sorted III Problem

LeetCode 960. You are given an array of n strings...

Count Unique Characters Of All Substrings Of A Given String Problem

LeetCode 828. Let’s define a function countUniqueChars(s) that returns the...

Cat And Mouse Problem

LeetCode 913. A game on an undirected graph is played...

Bitwise ORs Of Subarrays Problem

LeetCode 898. We have an array arr of non-negative integers....

Binary Trees With Factors Problem

LeetCode 823. Given an array of unique integers, arr, where...

Binary Tree Cameras Problem

LeetCode 968. You are given the root of a binary...

All Possible Full Binary Trees Problem

LeetCode 894. Given an integer n, return a list of...

Valid Parenthesis String Problem

LeetCode 678. Given a string s containing only three types...

Strange Printer Problem

LeetCode 664. There is a strange printer with the following...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Knight Probability In Chessboard Problem

LeetCode 688. On an n x n chessboard, a knight...

Cherry Pickup Problem

LeetCode 741. You are given an n x n grid...

2 Keys Keyboard Problem

LeetCode 650. There is only one character ‘A’ on the...

Rotated Digits Problem

LeetCode 788. An integer x is a good if after...

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Number Of Longest Increasing Subsequence Problem

LeetCode 673. Given an integer arraynums, return the number of...

Minimum Ascii Delete Sum For Two Strings Problem

LeetCode 712. Given two strings s1 ands2, return the lowest...

Min Cost Climbing Stairs Problem

LeetCode 746. You are given an integer array cost where...

Maximum Sum Of 3 Non-Overlapping Subarrays Problem

LeetCode 689. Given an integer array nums and an integer...

Maximum Length Of Repeated Subarray Problem

LeetCode 718. Given two integer arrays nums1 and nums2, return...

Maximum Length Of Pair Chain Problem

LeetCode 646. You are given an array of n pairs...

Palindromic Substrings Problem

LeetCode 647. Given a string s, return the number of...

Largest Plus Sign Problem

LeetCode 764. You are given an integer n. You have...

K Inverse Pairs Array Problem

LeetCode 629. For an integer array nums, an inverse pair...

Domino And Tromino Tiling Problem

LeetCode 790. You have two types of tiles, a 2...

Delete And Earn Problem

LeetCode 740. You are given an integer array nums. You...

Decode Ways II Problem

LeetCode 639. A message containing letters from A-Z can be...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

Champagne Tower Problem

LeetCode 799. We stack glasses in a pyramid, where the...

Zuma Game Problem

LeetCode 488. You are playing a variation of the game...

Predict The Winner Problem

LeetCode 486. You are given an integer array nums. Two...

Partition Equal Subset Sum Problem

LeetCode 416. Given a non-empty array nums containing only positive...

Non-Negative Integers Without Consecutive Ones Problem

LeetCode 600. Given a positive integer n, return the number...

Frog Jump Problem

LeetCode 403. A frog is crossing a river. The river...

Freedom Trail Problem

LeetCode 514. In the video game Fallout 4, the quest...

Target Sum Problem

LeetCode 494. You are given an integer array nums and...

Student Attendance Record II Problem

LeetCode 552. An attendance record for a student can be...

Split Array Largest Sum Problem

LeetCode 410. Given an array nums which consists of non-negative...

Remove Boxes Problem

LeetCode 546. You are given several boxes with different colors...

Poor Pigs Problem

LeetCode 458. There are buckets buckets of liquid, where exactly...

Out Of Boundary Paths Problem

LeetCode 576. There is an m x n grid with...

Optimal Division Problem

LeetCode 553. You are given an integer array nums. The...

Ones And Zeroes Problem

LeetCode 474. You are given an array of binary strings...

Non-Overlapping Intervals Problem

LeetCode 435. Given an array of intervals intervals where intervals[i]...

Matchsticks To Square Problem

LeetCode 473. You are given an integer array matchsticks where...

Longest Palindromic Subsequence Problem

LeetCode 516. Given a string s, find the longest palindromic...

Fibonacci Number Problem

LeetCode 509. The Fibonacci numbers, commonly denoted F(n) form a...

Delete Operation For Two Strings Problem

LeetCode 583. Given two strings word1 and word2, return the...

Coin Change II Problem

LeetCode 518. You are given an integer array coins representing...

Arithmetic Slices Problem

LeetCode 413. An integer array is called arithmetic if it...

Arithmetic Slices II - Subsequence Problem

LeetCode 446. Given an integer array nums, return the number...

01 Matrix Problem

LeetCode 542. Given an m x n binary matrix mat,...

Wiggle Subsequence Problem

LeetCode 376. A wiggle sequence is a sequence where the...

Ugly Number II Problem

LeetCode 264. An ugly number is a positive integer whose...

Rotate Function Problem

LeetCode 396. You are given an integer array nums of...

Perfect Squares Problem

LeetCode 279. Given an integer n, return the least number...

Number Of Digit One Problem

LeetCode 233. Given an integer n, count the total number...

Maximal Square Problem

LeetCode 221. Given an m x n binary matrix filled...

Longest Increasing Subsequence Problem

LeetCode 300. Given an integer array nums, return the length...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Largest Divisible Subset Problem

LeetCode 368. Given a set of distinct positive integers nums,...

Is Subsequence Problem

LeetCode 392. Given two strings s and t, return true...

Integer Replacement Problem

LeetCode 397. Given a positive integer n,you can apply one...

Integer Break Problem

LeetCode 343. Given an integer n, break it into the...

House Robber III Problem

LeetCode 337. The thief has found himself a new place...

House Robber II Problem

LeetCode 213. You are a professional robber planning to rob...

Guess Number Higher Or Lower II Problem

LeetCode 375. We are playing the Guessing Game. The game...

Different Ways To Add Parentheses Problem

LeetCode 241. Given a string expression of numbers and operators,...

Counting Bits Problem

LeetCode 338. Given an integer n, return an array ans...

Count Numbers With Unique Digits Problem

LeetCode 357. Given an integer n, return the count of...

Combination Sum IV Problem

LeetCode 377. Given an array of distinct integers nums and...

Coin Change Problem

LeetCode 322. You are given an integer array coins representing...

Burst Balloons Problem

LeetCode 312. You are given n balloons, indexed from 0...

Best Time To Buy And Sell Stock With Cooldown Problem

LeetCode 309. You are given an array prices where prices[i]...

Maximum Product Subarray Problem

LeetCode 152. Given an integer array nums, find a contiguous...

House Robber Problem

LeetCode 198. You are a professional robber planning to rob...

Dungeon Game Problem

LeetCode 174. The demons had captured the princess and imprisoned...

Best Time To Buy And Sell Stock IV Problem

LeetCode 188. You are given an integer array prices where...

Word Break Problem

LeetCode 139. Given a string s and a dictionary of...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Palindrome Partitioning Problem

LeetCode 131. Given a string s, partition s such that...

Palindrome Partitioning II Problem

LeetCode 132. Given a string s, partition s such that...

Triangle Problem

LeetCode 120. Given a triangle array, return the minimum path...

Pascal's Triangle Problem

LeetCode 118. Given an integer numRows, return the first numRows...

Pascal's Triangle II Problem

LeetCode 119. Given an integer rowIndex, return the rowIndex^th (0-indexed)...

Distinct Subsequences Problem

LeetCode 115. Given two strings s and t, return the...

Best Time To Buy And Sell Stock Problem

LeetCode 121. You are given an array prices where prices[i]...

Best Time To Buy And Sell Stock Iii Problem

LeetCode 123. You are given an array prices where prices[i]...

Best Time To Buy And Sell Stock Ii Problem

LeetCode 122. You are given an integer array prices where...

Interleaving String Problem

LeetCode 97. Given strings s1, s2, and s3, find whether...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Scramble String Problem

LeetCode 87. Given two strings s1 and s2 of the...

Maximal Rectangle Problem

LeetCode 85. Given a rows x cols binary matrix filled...

Decode Ways Problem

LeetCode 91. Given a string s containing only digits, return...

Edit Distance Problem

LeetCode 72. Given two strings word1 and word2, return the...

Unique Paths Problem

LeetCode 62. A robot is located at the top-left corner...

Unique Paths II Problem

LeetCode 63. A robot is located at the top-left corner...

Minimum Path Sum Problem

LeetCode 64. Given a m x n grid filled with...

Climbing Stairs Problem

LeetCode 70. You are climbing a staircase. It takes n...

Maximum Subarray Problem

LeetCode 53. Given an integer array nums, find the contiguous...

Jump Game Problem

LeetCode 55. Given an m x n matrix, return all...

Wildcard Matching Problem

LeetCode 44. Write the code that will take a string...

Trapping Rain Water Problem

LeetCode 42. Given n non-negative integers representing an elevation map...

Regular Expression Matching Problem

LeetCode 10. Given an input string s and a pattern...

Longest Valid Parentheses Problem

LeetCode 32. Given a string containing just the characters ‘(‘...

Jump Game II Problem

LeetCode 45. Given an array of non-negative integers nums, you...

Longest Palindromic Substring Problem

LeetCode 5. Given a string s, return the longest palindromic...

Generate Parentheses Problem

LeetCode 22. Given n pairs of parentheses, write a function...

Tag Array

X Of A Kind In A Deck Of Cards Problem

LeetCode 914. In a deck of cards, each card has...

Word Subsets Problem

LeetCode 916. You are given two string arrays words1 and...

Walking Robot Simulation Problem

LeetCode 874. A robot on an infinite XY-plane starts at...

Vowel Spellchecker Problem

LeetCode 966. Given a wordlist, we want to implement a...

Verifying An Alien Dictionary Problem

LeetCode 953. In an alien language, surprisingly, they also use...

Validate Stack Sequences Problem

LeetCode 946. Given two integer arrays pushed and popped each...

Valid Mountain Array Problem

LeetCode 941. Given an array of integers arr, return true...

Unique Paths III Problem

LeetCode 980. You are given an m x n integer...

Unique Morse Code Words Problem

LeetCode 804. International Morse Code defines a standard encoding where...

Unique Email Addresses Problem

LeetCode 929. Every valid email consists of a local name...

Triples With Bitwise And Equal To Zero Problem

LeetCode 982. Given an integer array nums, return the number...

Transpose Matrix Problem

LeetCode 867. Given a 2D integer array matrix, return the...

Three Equal Parts Problem

LeetCode 927. You are given an array arr which consists...

Tallest Billboard Problem

LeetCode 956. You are installing a billboard and want it...

Surface Area Of 3D Shapes Problem

LeetCode 892. You are given an n x n grid...

Sum Of Subsequence Widths Problem

LeetCode 891. The width of a sequence is the difference...

Sum Of Subarray Minimums Problem

LeetCode 907. Given an array of integers arr, find the...

Sum Of Even Numbers After Queries Problem

LeetCode 985. You are given an integer array nums and...

Subdomain Visit Count Problem

LeetCode 811. A website domain “discuss.leetcode.com” consists of various subdomains....

Subarrays With K Different Integers Problem

LeetCode 992. Given an integer array nums and an integer...

Stone Game Problem

LeetCode 877. Alice and Bob play a game with piles...

Squares Of A Sorted Array Problem

LeetCode 977. Given an integer array nums sorted in non-decreasing...

Split Array With Same Average Problem

LeetCode 805. You are given an integer array nums.

Spiral Matrix III Problem

LeetCode 885. You start at the cell (rStart, cStart) of...

Sort Array By Parity Problem

LeetCode 905. Given an integer array nums, move all the...

Sort Array By Parity II Problem

LeetCode 922. Given an array of integers nums, half of...

Sort An Array Problem

LeetCode 912. Given an array of integers nums, sort the...

Snakes And Ladders Problem

LeetCode 909. You are given an n x n integer...

Smallest Range II Problem

LeetCode 910. You are given an integer array nums and...

Smallest Range I Problem

LeetCode 908. You are given an integer array nums and...

Similar String Groups Problem

LeetCode 839. Two strings Xand Yare similar if we can...

Shortest Subarray With Sum At Least K Problem

LeetCode 862. Given an integer array nums and an integer...

Shortest Distance To A Character Problem

LeetCode 821. Given a string s and a character c...

Shortest Bridge Problem

LeetCode 934. You are given an n x n binary...

Short Encoding Of Words Problem

LeetCode 820. A valid encoding of an array of words...

Shifting Letters Problem

LeetCode 848. You are given a string s of lowercase...

Score After Flipping Matrix Problem

LeetCode 861. You are given an m x n binary...

Satisfiability Of Equality Equations Problem

LeetCode 990. You are given an array of strings equations...

Rotting Oranges Problem

LeetCode 994. You are given an m x n grid...

Rle Iterator Problem

LeetCode 900. We can use run-length encoding (i.e., RLE) to...

Reveal Cards In Increasing Order Problem

LeetCode 950. You are given an integer array deck. There...

Reorder Data In Log Files Problem

LeetCode 937. You are given an array of logs. Each...

Rectangle Area II Problem

LeetCode 850. You are given a 2D array of axis-aligned...

Projection Area Of 3D Shapes Problem

LeetCode 883. You are given an n x n grid...

Profitable Schemes Problem

LeetCode 879. There is a group of n members, and...

Prison Cells After N Days Problem

LeetCode 957. There are 8 prison cells in a row...

Peak Index In A Mountain Array Problem

LeetCode 852. Let’s call an array arr a mountainif the...

Partition Array Into Disjoint Intervals Problem

LeetCode 915. Given an integer array nums, partition it into...

Pancake Sorting Problem

LeetCode 969. Given an array of integers arr, sort the...

Online Election Problem

LeetCode 911. You are given two integer arrays persons and...

Odd Even Jump Problem

LeetCode 975. You are given an integer array arr. From...

Numbers At Most N Given Digit Set Problem

LeetCode 902. Given an array of digits which is sorted...

Number Of Squareful Arrays Problem

LeetCode 996. An array is squareful if the sum of...

Number Of Lines To Write String Problem

LeetCode 806. You are given a string s of lowercase...

Most Profit Assigning Work Problem

LeetCode 826. You have n jobs and m workers. You...

Monotonic Array Problem

LeetCode 896. An array is monotonic if it is either...

Minimum Number Of Refueling Stops Problem

LeetCode 871. A car travels from a starting position to...

Minimum Increment To Make Array Unique Problem

LeetCode 945. You are given an integer array nums. In...

Minimum Falling Path Sum Problem

LeetCode 931. Given an n x n array of integers...

Minimum Cost To Merge Stones Problem

LeetCode 1000. There are n piles of stones arranged in...

Minimum Cost To Hire K Workers Problem

LeetCode 857. There are n workers. You are given two...

Minimum Cost For Tickets Problem

LeetCode 983. You have planned some train traveling one year...

Minimum Area Rectangle Problem

LeetCode 939. You are given an array of points in...

Minimum Area Rectangle II Problem

LeetCode 963. You are given an array of points in...

Minimize Malware Spread Problem

LeetCode 924. You are given a network of n nodes...

Minimize Malware Spread II Problem

LeetCode 928. You are given a network of n nodes...

Maximum Width Ramp Problem

LeetCode 962. A ramp in an integer array nums is...

Maximum Sum Circular Subarray Problem

LeetCode 918. Given a circular integer array nums of length...

Maximize Distance To Closest Person Problem

LeetCode 849. You are given an array representing a row...

Max Increase To Keep City Skyline Problem

LeetCode 807. There is a city composed of n x...

Making A Large Island Problem

LeetCode 827. You are given an n x n binary...

Magic Squares In Grid Problem

LeetCode 840. A 3 x 3 magic square is a...

Loud And Rich Problem

LeetCode 851. There is a group of n people labeled...

Longest Turbulent Subarray Problem

LeetCode 978. Given an integer array arr, return the length...

Longest Mountain In Array Problem

LeetCode 845. Given an integer array arr, return the length...

Linked List Components Problem

LeetCode 817. You are given the head of a linked...

Length Of Longest Fibonacci Subsequence Problem

LeetCode 873. Given a strictly increasing array arr of positive...

Lemonade Change Problem

LeetCode 860. At a lemonade stand, each lemonade costs $5....

Largest Triangle Area Problem

LeetCode 812. Given an array of points on the X-Y...

Largest Sum Of Averages Problem

LeetCode 813. You are given an integer array nums and...

Largest Perimeter Triangle Problem

LeetCode 976. Given an integer array nums, return the largest...

Largest Component Size By Common Factor Problem

LeetCode 952. You are given an integer array of unique...

Koko Eating Bananas Problem

LeetCode 875. Koko loves to eat bananas. There are n...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Interval List Intersections Problem

LeetCode 986. You are given two lists of closed intervals,...

Image Overlap Problem

LeetCode 835. You are given two images, img1 and img2,...

Hand Of Straights Problem

LeetCode 846. Alice has some number of cards and she...

Guess The Word Problem

LeetCode 843. This is an interactive problem.

Groups Of Special-Equivalent Strings Problem

LeetCode 893. You are given an array of strings of...

Fruit Into Baskets Problem

LeetCode 904. You are visiting a farm that has a...

Friends Of Appropriate Ages Problem

LeetCode 825. There are n persons on a social media...

Flipping An Image Problem

LeetCode 832. Given an n x n binary matrix image,...

Find The Town Judge Problem

LeetCode 997. In a town, there are n people labeled...

Find The Shortest Superstring Problem

LeetCode 943. Given an array of strings words, return the...

Find And Replace Pattern Problem

LeetCode 890. Given a list of strings words and a...

Find And Replace In String Problem

LeetCode 833. You are given a 0-indexed string s that...

Fair Candy Swap Problem

LeetCode 888. Alice and Bob have a different total number...

Expressive Words Problem

LeetCode 809. Sometimes people repeat letters to represent extra feeling....

DI String Match Problem

LeetCode 942. A permutation perm of n + 1 integers...

Delete Columns To Make Sorted Problem

LeetCode 944. You are given an array of n strings...

Delete Columns To Make Sorted III Problem

LeetCode 960. You are given an array of n strings...

Delete Columns To Make Sorted II Problem

LeetCode 955. You are given an array of n strings...

Construct Binary Tree From Preorder And Postorder Traversal Problem

LeetCode 889. Given two integer arrays, preorder and postorder where...

Chalkboard Xor Game Problem

LeetCode 810. You are given an array of integers nums...

Card Flipping Game Problem

LeetCode 822. You are given n cards, with a positive...

Car Fleet Problem

LeetCode 853. There are n cars going to the same...

Bus Routes Problem

LeetCode 815. You are given an array routes representing bus...

Bricks Falling When Hit Problem

LeetCode 803. You are given an m x n binary...

Boats To Save People Problem

LeetCode 881. You are given an array people where people[i]...

Bitwise ORs Of Subarrays Problem

LeetCode 898. We have an array arr of non-negative integers....

Binary Trees With Factors Problem

LeetCode 823. Given an array of unique integers, arr, where...

Binary Subarrays With Sum Problem

LeetCode 930. Given a binary array nums and an integer...

Beautiful Array Problem

LeetCode 932. Given the integer n, return any beautiful array...

Bag Of Tokens Problem

LeetCode 948. You have an initial power of power, an...

Available Captures For Rook Problem

LeetCode 999. On an 8 x 8 chessboard, there is...

Array Of Doubled Pairs Problem

LeetCode 954. Given an integer array of even length arr,...

Advantage Shuffle Problem

LeetCode 870. You are given two integer arrays nums1 and...

Add To Array-Form Of Integer Problem

LeetCode 989. The array-form of an integer num is an...

3Sum With Multiplicity Problem

LeetCode 923. Given an integer array arr, and an integer...

Valid Triangle Number Problem

LeetCode 611. Given an integer array nums, return the number...

Valid Tic-Tac-Toe State Problem

LeetCode 794. Given a Tic-Tac-Toe board as a string array...

Transform To Chessboard Problem

LeetCode 782. You are given an n x n binary...

Toeplitz Matrix Problem

LeetCode 766. Given an m x n matrix, returntrueif the...

Task Scheduler Problem

LeetCode 621. Given a characters array tasks, representing the tasks...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Sliding Puzzle Problem

LeetCode 773. On an 2 x 3 board, there are...

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Set Mismatch Problem

LeetCode 645. You have a set of integers s, which...

Set Intersection Size At Least Two Problem

LeetCode 757. You are given a 2D integer array intervals...

Rabbits In Forest Problem

LeetCode 781. There is a forest with an unknown number...

Open The Lock Problem

LeetCode 752. You have a lock in front of you...

Find Pivot Index Problem

LeetCode 724. Given an array of integers nums, calculate the...

Exclusive Time Of Functions Problem

LeetCode 636. On a single-threaded CPU, we execute a program...

Escape The Ghosts Problem

LeetCode 789. You are playing a simplified PAC-MAN game on...

Cherry Pickup Problem

LeetCode 741. You are given an n x n grid...

Split Array Into Consecutive Subsequences Problem

LeetCode 659. You are given an integer array nums that...

Smallest Rotation With Highest Score Problem

LeetCode 798. You are given an array nums. You can...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Shortest Completing Word Problem

LeetCode 748. Given a string licensePlate and an array of...

Remove Comments Problem

LeetCode 722. Given a C++ program, remove comments from it....

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Number Of Subarrays With Bounded Maximum Problem

LeetCode 795. Given an integer array nums and two integers...

Number Of Longest Increasing Subsequence Problem

LeetCode 673. Given an integer arraynums, return the number of...

Non-Decreasing Array Problem

LeetCode 665. Given an array nums with n integers, your...

Min Cost Climbing Stairs Problem

LeetCode 746. You are given an integer array cost where...

Maximum Sum Of 3 Non-Overlapping Subarrays Problem

LeetCode 689. Given an integer array nums and an integer...

Maximum Product Of Three Numbers Problem

LeetCode 628. Given an integer array nums, find three numbers...

Maximum Length Of Repeated Subarray Problem

LeetCode 718. Given two integer arrays nums1 and nums2, return...

Maximum Length Of Pair Chain Problem

LeetCode 646. You are given an array of n pairs...

Max Chunks To Make Sorted Problem

LeetCode 769. You are given an integer array arr of...

Max Chunks To Make Sorted II Problem

LeetCode 768. You are given an integer array arr.

Longest Continuous Increasing Subsequence Problem

LeetCode 674. Given an unsorted array of integers nums, return...

Image Smoother Problem

LeetCode 661. An image smoother is a filter of the...

Global And Local Inversions Problem

LeetCode 775. You are given an integer array nums of...

Flood Fill Problem

LeetCode 733. An image is represented by an m x...

Find Smallest Letter Greater Than Target Problem

LeetCode 744. Given a characters array letters that is sorted...

Find Duplicate File In System Problem

LeetCode 609. Given a list paths of directory info, including...

Falling Squares Problem

LeetCode 699. There are several squares being dropped onto the...

Design Circular Queue Problem

LeetCode 622. Design your implementation of the circular queue. The...

Design Circular Deque Problem

LeetCode 641. Design your implementation of the circular double-ended queue...

Cut Off Trees For Golf Event Problem

LeetCode 675. You are asked to cut off all the...

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Maximum Average Subarray I Problem

LeetCode 643. You are given an integer array nums consisting...

Max Area Of Island Problem

LeetCode 695. You are given an m x n binary...

Largest Plus Sign Problem

LeetCode 764. You are given an integer n. You have...

Largest Number At Least Twice Of Others Problem

LeetCode 747. You are given an integer array nums where...

K-Th Smallest Prime Fraction Problem

LeetCode 786. You are given a sorted integer array arr...

Find K-Th Smallest Pair Distance Problem

LeetCode 719. The distance of a pair of integers a...

Find K Closest Elements Problem

LeetCode 658. Given a sorted integer array arr, two integers...

Design Hashset Problem

LeetCode 705. Design a HashSet without using any built-in hash...

Design Hashmap Problem

LeetCode 706. Design a HashMap without using any built-in hash...

Delete And Earn Problem

LeetCode 740. You are given an integer array nums. You...

Degree Of An Array Problem

LeetCode 697. Given a non-empty array of non-negative integers nums,...

Daily Temperatures Problem

LeetCode 739. Given an array of integers temperatures represents the...

Course Schedule III Problem

LeetCode 630. There are n different online courses numbered from...

Contain Virus Problem

LeetCode 749. A virus is spreading rapidly, and your task...

Can Place Flowers Problem

LeetCode 605. You have a long flowerbed in which some...

Binary Search Problem

LeetCode 704. Given an array of integers nums which is...

Beautiful Arrangement II Problem

LeetCode 667. Given two integers n and k, construct a...

Baseball Game Problem

LeetCode 682. You are keeping score for a baseball game...

Asteroid Collision Problem

LeetCode 735. We are given an array asteroids of integers...

Accounts Merge Problem

LeetCode 721. Given a list of accounts where each element...

24 Game Problem

LeetCode 679. You are given an integer array cards of...

1-Bit And 2-Bit Characters Problem

LeetCode 717. We have two special characters, the first character...

Trapping Rain Water II Problem

LeetCode 407. Given an m x n integer matrix heightMap...

Total Hamming Distance Problem

LeetCode 477. The Hamming distance between two integers is the...

Third Maximum Number Problem

LeetCode 414. Given an integer array nums, return the third...

Teemo Attacking Problem

LeetCode 495. Our hero Teemo is attacking an enemy Ashe...

Super Washing Machines Problem

LeetCode 517. You have n super washing machines on a...

Predict The Winner Problem

LeetCode 486. You are given an integer array nums. Two...

Partition Equal Subset Sum Problem

LeetCode 416. Given a non-empty array nums containing only positive...

Pacific Atlantic Water Flow Problem

LeetCode 417. There is an m x n rectangular island...

IPO Problem

LeetCode 502. Suppose LeetCode will start its IPO soon. In...

Frog Jump Problem

LeetCode 403. A frog is crossing a river. The river...

Erect The Fence Problem

LeetCode 587. You are given an array trees where trees[i]...

Target Sum Problem

LeetCode 494. You are given an integer array nums and...

Split Array Largest Sum Problem

LeetCode 410. Given an array nums which consists of non-negative...

Sliding Window Median Problem

LeetCode 480. The median is the middle value in an...

Single Element In A Sorted Array Problem

LeetCode 540. You are given a sorted array consisting of...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Reverse Pairs Problem

LeetCode 493. Given an integer array nums, return the number...

Reshape The Matrix Problem

LeetCode 566. In MATLAB, there is a handy function called...

Remove Boxes Problem

LeetCode 546. You are given several boxes with different colors...

Relative Ranks Problem

LeetCode 506. You are given an integer array score of...

Range Addition II Problem

LeetCode 598. You are given an m x n matrix...

Queue Reconstruction By Height Problem

LeetCode 406. You are given an array of people, people,...

Optimal Division Problem

LeetCode 553. You are given an integer array nums. The...

Ones And Zeroes Problem

LeetCode 474. You are given an array of binary strings...

Number Of Boomerangs Problem

LeetCode 447. You are given n points in the plane...

Non-Overlapping Intervals Problem

LeetCode 435. Given an array of intervals intervals where intervals[i]...

Next Greater Element II Problem

LeetCode 503. Given a circular integer array nums (i.e., the...

Next Greater Element I Problem

LeetCode 496. The next greater element of some element x...

Minimum Time Difference Problem

LeetCode 539. Given a list of 24-hour clock time points...

Minimum Number Of Arrows To Burst Balloons Problem

LeetCode 452. There are some spherical balloons taped onto a...

Minimum Moves To Equal Array Elements Problem

LeetCode 453. Given an integer array nums of size n,...

Minimum Moves To Equal Array Elements II Problem

LeetCode 462. Given an integer array nums of size n,...

Minimum Index Sum Of Two Lists Problem

LeetCode 599. Suppose Andy and Doris want to choose a...

Minesweeper Problem

LeetCode 529. Let’s play the minesweeper game!

Max Consecutive Ones Problem

LeetCode 485. Given a binary array nums, return the maximum...

Matchsticks To Square Problem

LeetCode 473. You are given an integer array matchsticks where...

Longest Uncommon Subsequence II Problem

LeetCode 522. Given an array of strings strs, return the...

Longest Harmonious Subsequence Problem

LeetCode 594. We define a harmonious array as an array...

Keyboard Row Problem

LeetCode 500. Given an array of strings words, return the...

K-Diff Pairs In An Array Problem

LeetCode 532. Given an array of integers nums and an...

Island Perimeter Problem

LeetCode 463. You are given row x col grid representing...

Increasing Subsequences Problem

LeetCode 491. Given an integer array nums, return all the...

Heaters Problem

LeetCode 475. Winter is coming! During the contest, your first...

Find Right Interval Problem

LeetCode 436. You are given an array of intervals, where...

Find All Numbers Disappeared In An Array Problem

LeetCode 448. Given an array nums of n integers where...

Find All Duplicates In An Array Problem

LeetCode 442. Given an integer array nums of length n...

Distribute Candies Problem

LeetCode 575. Alice has n candies, where the i^th candy...

Diagonal Traverse Problem

LeetCode 498. Given an m x n matrix mat, return...

Contiguous Array Problem

LeetCode 525. Given a binary array nums, return the maximum...

Construct Quad Tree Problem

LeetCode 427. Given a n * n matrix grid of...

UTF-8 Validation Problem

LeetCode 393. Given an integer array data representing the data,...

Coin Change II Problem

LeetCode 518. You are given an integer array coins representing...

Circular Array Loop Problem

LeetCode 457. You are playing a game involving a circular...

Brick Wall Problem

LeetCode 554. There is a rectangular brick wall in front...

Beautiful Arrangement Problem

LeetCode 526. Suppose you have n integers labeled 1 through...

Battleships In A Board Problem

LeetCode 419. Given an m x n matrix board where...

Assign Cookies Problem

LeetCode 455. Assume you are an awesome parent and want...

Array Partition I Problem

LeetCode 561. Given an integer array nums of 2n integers,...

Array Nesting Problem

LeetCode 565. You are given an integer array nums of...

Arithmetic Slices Problem

LeetCode 413. An integer array is called arithmetic if it...

Arithmetic Slices II - Subsequence Problem

LeetCode 446. Given an integer array nums, return the number...

132 Pattern Problem

LeetCode 456. Given an arrayof n integers nums, a 132...

01 Matrix Problem

LeetCode 542. Given an m x n binary matrix mat,...

Wiggle Subsequence Problem

LeetCode 376. A wiggle sequence is a sequence where the...

Top K Frequent Elements Problem

LeetCode 347. Given an integer array nums and an integer...

Super Ugly Number Problem

LeetCode 313. A super ugly number is a positive integer...

Summary Ranges Problem

LeetCode 228. You are given a sorted unique integer array...

Sliding Window Maximum Problem

LeetCode 239. You are given an array of integersnums, there...

Single Number III Problem

LeetCode 260. Given an integer array nums, in which exactly...

Shuffle An Array Problem

LeetCode 384. Given an integer array nums, design an algorithm...

Self Crossing Problem

LeetCode 335. You are given an array of integers distance....

Search A 2D Matrix II Problem

LeetCode 240. Write an efficient algorithm that searches for a...

Rotate Function Problem

LeetCode 396. You are given an integer array nums of...

Range Sum Query - Immutable Problem

LeetCode 303. Given an integer array nums, handle multiple queries...

Range Sum Query 2D - Immutable Problem

LeetCode 304. Given a 2D matrix matrix, handle multiple queries...

Product Of Array Except Self Problem

LeetCode 238. Given an integer array nums, return an array...

Perfect Rectangle Problem

LeetCode 391. Given an array rectangles where rectangles[i] = [x_i,...

Peeking Iterator Problem

LeetCode 284. Design an iterator that supports the peek operation...

Patching Array Problem

LeetCode 330. Given a sorted integer array nums and an...

Palindrome Pairs Problem

LeetCode 336. Given a list of unique words, return all...

Move Zeroes Problem

LeetCode 283. Given an integer array nums, move all 0’s...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Minimum Size Subarray Sum Problem

LeetCode 209. Given an array of positive integers nums and...

Maximum Product Of Word Lengths Problem

LeetCode 318. Given a string array words, return the maximum...

Maximal Square Problem

LeetCode 221. Given an m x n binary matrix filled...

Majority Element II Problem

LeetCode 229. Given an integer array of size n, find...

Longest Increasing Subsequence Problem

LeetCode 300. Given an integer array nums, return the length...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Largest Divisible Subset Problem

LeetCode 368. Given a set of distinct positive integers nums,...

Kth Largest Element In An Array Problem

LeetCode 215. Given an integer array nums and an integer...

Intersection Of Two Arrays II Problem

LeetCode 350. Given two integer arrays nums1 and nums2, return...

Insert Delete Getrandom O(1) - Duplicates Allowed Problem

LeetCode 381. RandomizedCollection is a data structure that contains a...

Increasing Triplet Subsequence Problem

LeetCode 334. Given an integer array nums, return true if...

House Robber II Problem

LeetCode 213. You are a professional robber planning to rob...

H-Index Problem

LeetCode 274. Given an array of integers citations where citations[i]...

H-Index II Problem

LeetCode 275. Given an array of integers citations where citations[i]...

Game Of Life Problem

LeetCode 289. The Game of Life, also known simply as...

Find The Duplicate Number Problem

LeetCode 287. Given an array of integers nums containingn +...

Find K Pairs With Smallest Sums Problem

LeetCode 373. You are given two integer arrays nums1 and...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Count Primes Problem

LeetCode 204. Given an integer n, return the number of...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Contains Duplicate Problem

LeetCode 217. Given an integer array nums, return true if...

Contains Duplicate III Problem

LeetCode 220. Given an integer array nums and two integers...

Contains Duplicate II Problem

LeetCode 219. Given an integer array nums and an integer...

Combination Sum IV Problem

LeetCode 377. Given an array of distinct integers nums and...

Combination Sum III Problem

LeetCode 216. Find all valid combinations of k numbers that...

Coin Change Problem

LeetCode 322. You are given an integer array coins representing...

Burst Balloons Problem

LeetCode 312. You are given n balloons, indexed from 0...

Best Time To Buy And Sell Stock With Cooldown Problem

LeetCode 309. You are given an array prices where prices[i]...

Rotate Array Problem

LeetCode 189. Given an array, rotate the array to the...

Maximum Product Subarray Problem

LeetCode 152. Given an integer array nums, find a contiguous...

Maximum Gap Problem

LeetCode 164. Given an integer array nums, return the maximum...

Majority Element Problem

LeetCode 169. Given an array nums of size n, return...

House Robber Problem

LeetCode 198. You are a professional robber planning to rob...

Find Peak Element Problem

LeetCode 162. A peak element is an element that is...

Find Minimum In Rotated Sorted Array Problem

LeetCode 153. Suppose an array of length n sorted in...

Find Minimum In Rotated Sorted Array II Problem

LeetCode 154. Suppose an array of length n sorted in...

Dungeon Game Problem

LeetCode 174. The demons had captured the princess and imprisoned...

Best Time To Buy And Sell Stock IV Problem

LeetCode 188. You are given an integer array prices where...

Single Number Problem

LeetCode 136. Given a non-empty array of integers nums, every...

Single Number II Problem

LeetCode 137. Given an integer array nums whereevery element appears...

Gas Station Problem

LeetCode 134. There are n gas stations along a circular...

Evaluate Reverse Polish Notation Problem

LeetCode 150. Evaluate the value of an arithmetic expression in...

Candy Problem

LeetCode 135. There are n children standing in a line....

Triangle Problem

LeetCode 120. Given a triangle array, return the minimum path...

Surrounded Regions Problem

LeetCode 130. Given an m x n matrix board containing...

Pascal's Triangle Problem

LeetCode 118. Given an integer numRows, return the first numRows...

Pascal's Triangle II Problem

LeetCode 119. Given an integer rowIndex, return the rowIndex^th (0-indexed)...

Longest Consecutive Sequence Problem

LeetCode 128. Given an unsorted array of integers nums, return...

Best Time To Buy And Sell Stock Problem

LeetCode 121. You are given an array prices where prices[i]...

Best Time To Buy And Sell Stock Iii Problem

LeetCode 123. You are given an array prices where prices[i]...

Best Time To Buy And Sell Stock Ii Problem

LeetCode 122. You are given an integer array prices where...

Convert Sorted Array to Binary Search Tree Problem

LeetCode 108. Given an integer array nums where the elements...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Word Search Problem

LeetCode 79. Given an m x n grid of characters...

Subsets Problem

LeetCode 78. Given an integer array nums of unique elements,...

Subsets II Problem

LeetCode 90. Given an integer array nums that may contain...

Search in Rotated Sorted Array II Problem

LeetCode 81. There is an integer array nums sorted in...

Remove Duplicates from Sorted Array II Problem

LeetCode 80. Given an integer array nums sorted in non-decreasing...

Merge Sorted Array Problem

LeetCode 88. You are given two integer arrays nums1 and...

Maximal Rectangle Problem

LeetCode 85. Given a rows x cols binary matrix filled...

Largest Rectangle in Histogram Problem

LeetCode 84. Given an array of integers heights representing the...

Sort Colors Problem

LeetCode 75. Given an array nums with n objects colored...

Set Matrix Zeroes Problem

LeetCode 73. Given an m x n integer matrix matrix,...

Search A 2D Matrix Problem

LeetCode 74. Write an efficient algorithm that searches for a...

Combinations Problem

LeetCode 77. Given two integers n and k, return all...

Plus One Problem

LeetCode 66. You are given a large integer represented as...

Minimum Path Sum Problem

LeetCode 64. Given a m x n grid filled with...

Spiral Matrix Problem

LeetCode 54. Given an m x n matrix, return all...

Spiral Matrix II Problem

LeetCode 59. Given a positive integer n, generate an n...

N-Queens Problem

LeetCode 51. Given an integer n, return all distinct solutions...

N-Queens II Problem

LeetCode 52. Given an integer n, return the number of...

Maximum Subarray Problem

LeetCode 53. Given an integer array nums, find the contiguous...

Jump Game Problem

LeetCode 55. Given an m x n matrix, return all...

Insert Interval Problem

LeetCode 57. Insert newInterval into intervals such that intervals is...

Search in Rotated Sorted Array Problem

LeetCode 36. Determine if a 9 x 9 Sudoku board...

Trapping Rain Water Problem

LeetCode 42. Given n non-negative integers representing an elevation map...

Sudoku Solver Problem

LeetCode 37. Write a program to solve a Sudoku puzzle...

Search in Rotated Sorted Array Problem

LeetCode 33. Given the array nums after the possible rotation...

Rotate Image Problem

LeetCode 48. Determine if a 9 x 9 Sudoku board...

Remove Element Problem

LeetCode 27. Given an integer array nums and an integer...

Permutations Problem

LeetCode 46. Given an array nums of distinct integers, return...

Permutations II Problem

LeetCode 47. Given a collection of numbers, nums, that might...

Next Permutation Problem

LeetCode 31. Implement next permutation, which rearranges numbers into the...

Jump Game II Problem

LeetCode 45. Given an array of non-negative integers nums, you...

First Missing Positive Problem

LeetCode 41. Given an unsorted integer array nums, return the...

Find First and Last Position of Element in Sorted Array Problem

LeetCode 34. Given the array nums after the possible rotation...

Combination Sum Problem

LeetCode 39. Given an array of distinct integers candidates and...

Combination Sum II Problem

LeetCode 40. Given a collection of candidate numbers (candidates) and...

3Sum Closest Problem

LeetCode 16. Given an integer array nums of length n...

Remove Duplicates from Sorted Array Problem

LeetCode 26. Given an integer array nums sorted in non-decreasing...

Tag Math

X Of A Kind In A Deck Of Cards Problem

LeetCode 914. In a deck of cards, each card has...

Three Equal Parts Problem

LeetCode 927. You are given an array arr which consists...

Surface Area Of 3D Shapes Problem

LeetCode 892. You are given an n x n grid...

Super Palindromes Problem

LeetCode 906. Let’s say a positive integer is a super-palindrome...

Super Egg Drop Problem

LeetCode 887. You are given k identical eggs and you...

Sum Of Subsequence Widths Problem

LeetCode 891. The width of a sequence is the difference...

Stone Game Problem

LeetCode 877. Alice and Bob play a game with piles...

Split Array With Same Average Problem

LeetCode 805. You are given an integer array nums.

Soup Servings Problem

LeetCode 808. There are two types of soup, type A...

Smallest Range II Problem

LeetCode 910. You are given an integer array nums and...

Smallest Range I Problem

LeetCode 908. You are given an integer array nums and...

Reordered Power Of 2 Problem

LeetCode 869. You are given an integer n. We reorder...

Rectangle Overlap Problem

LeetCode 836. An axis-aligned rectangle is represented as a list...

Projection Area Of 3D Shapes Problem

LeetCode 883. You are given an n x n grid...

Prison Cells After N Days Problem

LeetCode 957. There are 8 prison cells in a row...

Prime Palindrome Problem

LeetCode 866. Given an integer n, return the smallest prime...

Powerful Integers Problem

LeetCode 970. Given three integers x, y, and bound, return...

Orderly Queue Problem

LeetCode 899. You are given a string s and an...

Numbers At Most N Given Digit Set Problem

LeetCode 902. Given an array of digits which is sorted...

Number Of Squareful Arrays Problem

LeetCode 996. An array is squareful if the sum of...

Number Of Music Playlists Problem

LeetCode 920. Your music player contains n different songs. You...

Nth Magical Number Problem

LeetCode 878. A positive integer is magical if it is...

New 21 Game Problem

LeetCode 837. Alice plays the following game, loosely based on...

Mirror Reflection Problem

LeetCode 858. There is a special square room with mirrors...

Minimum Area Rectangle Problem

LeetCode 939. You are given an array of points in...

Minimum Area Rectangle II Problem

LeetCode 963. You are given an array of points in...

Magic Squares In Grid Problem

LeetCode 840. A 3 x 3 magic square is a...

Least Operators To Express Number Problem

LeetCode 964. Given a single positive integer x, we will...

Largest Triangle Area Problem

LeetCode 812. Given an array of points on the X-Y...

Largest Perimeter Triangle Problem

LeetCode 976. Given an integer array nums, return the largest...

Largest Component Size By Common Factor Problem

LeetCode 952. You are given an integer array of unique...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Guess The Word Problem

LeetCode 843. This is an interactive problem.

Equal Rational Numbers Problem

LeetCode 972. Given two strings s and t, each of...

Consecutive Numbers Sum Problem

LeetCode 829. Given an integer n, return the number of...

Chalkboard Xor Game Problem

LeetCode 810. You are given an array of integers nums...

Cat And Mouse Problem

LeetCode 913. A game on an undirected graph is played...

Broken Calculator Problem

LeetCode 991. There is a broken calculator that has the...

Beautiful Array Problem

LeetCode 932. Given the integer n, return any beautiful array...

Add To Array-Form Of Integer Problem

LeetCode 989. The array-form of an integer num is an...

Transform To Chessboard Problem

LeetCode 782. You are given an n x n binary...

Solve The Equation Problem

LeetCode 640. Solve a given equation and return the value...

Self Dividing Numbers Problem

LeetCode 728. A self-dividing number is a number that is...

Reaching Points Problem

LeetCode 780. Given four integers sx, sy, tx, and ty,...

Random Pick With Blacklist Problem

LeetCode 710. You are given an integer n and an...

Rabbits In Forest Problem

LeetCode 781. There is a forest with an unknown number...

K-Th Symbol In Grammar Problem

LeetCode 779. We build a table of n rows (1-indexed)....

Escape The Ghosts Problem

LeetCode 789. You are playing a simplified PAC-MAN game on...

2 Keys Keyboard Problem

LeetCode 650. There is only one character ‘A’ on the...

Sum Of Square Numbers Problem

LeetCode 633. Given a non-negative integer c, decide whether there’re...

Rotated Digits Problem

LeetCode 788. An integer x is a good if after...

Reach A Number Problem

LeetCode 754. You are standing at position 0 on an...

Prime Number Of Set Bits In Binary Representation Problem

LeetCode 762. Given two integers left and right, return the...

Monotone Increasing Digits Problem

LeetCode 738. An integer has monotone increasing digits if and...

Maximum Product Of Three Numbers Problem

LeetCode 628. Given an integer array nums, find three numbers...

Kth Smallest Number In Multiplication Table Problem

LeetCode 668. Nearly everyone has used the Multiplication Table. The...

Global And Local Inversions Problem

LeetCode 775. You are given an integer array nums of...

Maximum Swap Problem

LeetCode 670. You are given an integer num. You can...

Bulb Switcher II Problem

LeetCode 672. There is a room with n bulbs labeled...

Beautiful Arrangement II Problem

LeetCode 667. Given two integers n and k, construct a...

Basic Calculator IV Problem

LeetCode 770. Given an expression such as expression = “e...

24 Game Problem

LeetCode 679. You are given an integer array cards of...

Total Hamming Distance Problem

LeetCode 477. The Hamming distance between two integers is the...

Random Point In Non-Overlapping Rectangles Problem

LeetCode 497. You are given an array of non-overlapping axis-aligned...

Predict The Winner Problem

LeetCode 486. You are given an integer array nums. Two...

Find The Closest Palindrome Problem

LeetCode 564. Given a string n representing an integer, return...

Erect The Fence Problem

LeetCode 587. You are given an array trees where trees[i]...

Valid Square Problem

LeetCode 593. Given the coordinates of four points in 2D...

Smallest Good Base Problem

LeetCode 483. Given an integer n represented as a string,...

Reconstruct Original Digits From English Problem

LeetCode 423. Given a string s containing an out-of-order English...

Range Addition II Problem

LeetCode 598. You are given an m x n matrix...

Random Pick With Weight Problem

LeetCode 528. You are given a 0-indexed array of positive...

Random Flip Matrix Problem

LeetCode 519. There is an m x n binary grid...

Poor Pigs Problem

LeetCode 458. There are buckets buckets of liquid, where exactly...

Perfect Number Problem

LeetCode 507. A perfect number is a positive integer that...

Optimal Division Problem

LeetCode 553. You are given an integer array nums. The...

Number Of Boomerangs Problem

LeetCode 447. You are given n points in the plane...

Next Greater Element III Problem

LeetCode 556. Given a positive integer n, find the smallest...

Minimum Time Difference Problem

LeetCode 539. Given a list of 24-hour clock time points...

Minimum Moves To Equal Array Elements Problem

LeetCode 453. Given an integer array nums of size n,...

Minimum Moves To Equal Array Elements II Problem

LeetCode 462. Given an integer array nums of size n,...

Largest Palindrome Product Problem

LeetCode 479. Given an integer n, return the largest palindromic...

K-Th Smallest In Lexicographical Order Problem

LeetCode 440. Given two integers n and k, return the...

Implement Rand10() Using Rand7() Problem

LeetCode 470. Given the API rand7() that generates a uniform...

Generate Random Point In A Circle Problem

LeetCode 478. Given the radius and the position of the...

Fraction Addition And Subtraction Problem

LeetCode 592. Given a string expression representing an expression of...

Fibonacci Number Problem

LeetCode 509. The Fibonacci numbers, commonly denoted F(n) form a...

Convert A Number To Hexadecimal Problem

LeetCode 405. Given an integer num, return a string representing...

Construct The Rectangle Problem

LeetCode 492. A web developer needs to know how to...

Complex Number Multiplication Problem

LeetCode 537. A complex number can be represented as a...

Water And Jug Problem Problem

LeetCode 365. You are given two jugs with capacities jug1Capacity...

Fizz Buzz Problem

LeetCode 412. Given an integer n, return a string array...

Can I Win Problem

LeetCode 464. In the “100 game” two players take turns...

Base 7 Problem

LeetCode 504. Given an integer num, return a string of...

Arranging Coins Problem

LeetCode 441. You have n coins and you want to...

Add Two Numbers II Problem

LeetCode 445. You are given two non-empty linked lists representing...

Add Strings Problem

LeetCode 415. Given two non-negative integers, num1 and num2 represented...

Ugly Number Problem

LeetCode 263. An ugly number is a positive integer whose...

Ugly Number II Problem

LeetCode 264. An ugly number is a positive integer whose...

Super Ugly Number Problem

LeetCode 313. A super ugly number is a positive integer...

Super Pow Problem

LeetCode 372. Your task is to calculate a^b mod 1337...

Sum Of Two Integers Problem

LeetCode 371. Given two integers a and b, return the...

Shuffle An Array Problem

LeetCode 384. Given an integer array nums, design an algorithm...

Self Crossing Problem

LeetCode 335. You are given an array of integers distance....

Rotate Function Problem

LeetCode 396. You are given an integer array nums of...

Rectangle Area Problem

LeetCode 223. Given the coordinates of two rectilinear rectangles in...

Random Pick Index Problem

LeetCode 398. Given an integer array nums with possible duplicates,...

Power Of Two Problem

LeetCode 231. Given an integer n, return true if it...

Power Of Three Problem

LeetCode 326. Given an integer n, return true if it...

Power Of Four Problem

LeetCode 342. Given an integer n, return true if it...

Perfect Squares Problem

LeetCode 279. Given an integer n, return the least number...

Number Of Digit One Problem

LeetCode 233. Given an integer n, count the total number...

Nth Digit Problem

LeetCode 400. Given an integer n, return the n^th digit...

Nim Game Problem

LeetCode 292. You are playing the following Nim Game with...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Linked List Random Node Problem

LeetCode 382. Given a singly linked list, return a random...

Lexicographical Numbers Problem

LeetCode 386. Given an integer n, return all the numbers...

Largest Divisible Subset Problem

LeetCode 368. Given a set of distinct positive integers nums,...

Integer To English Words Problem

LeetCode 273. Convert a non-negative integer num to its English...

Integer Break Problem

LeetCode 343. Given an integer n, break it into the...

Insert Delete Getrandom O(1) - Duplicates Allowed Problem

LeetCode 381. RandomizedCollection is a data structure that contains a...

Happy Number Problem

LeetCode 202. Write an algorithm to determine if a number...

Guess Number Higher Or Lower II Problem

LeetCode 375. We are playing the Guessing Game. The game...

Expression Add Operators Problem

LeetCode 282. Given a string num that contains only digits...

Elimination Game Problem

LeetCode 390. You have a list arr of all integers...

Different Ways To Add Parentheses Problem

LeetCode 241. Given a string expression of numbers and operators,...

Count Primes Problem

LeetCode 204. Given an integer n, return the number of...

Count Numbers With Unique Digits Problem

LeetCode 357. Given an integer n, return the count of...

Bulb Switcher Problem

LeetCode 319. There are n bulbs that are initially off....

Basic Calculator Problem

LeetCode 224. Given a string s representing a valid expression,...

Basic Calculator II Problem

LeetCode 227. Given a string s which represents an expression,...

Add Digits Problem

LeetCode 258. Given an integer num, repeatedly add all its...

Rotate Array Problem

LeetCode 189. Given an array, rotate the array to the...

Fraction To Recurring Decimal Problem

LeetCode 166. Given two integers representing the numerator and denominator...

Factorial Trailing Zeroes Problem

LeetCode 172. Given an integer n, return the number of...

Excel Sheet Column Title Problem

LeetCode 168. Given an integer columnNumber, return its corresponding column...

Excel Sheet Column Number Problem

LeetCode 171. Given a string columnTitle that represents the column...

Max Points On A Line Problem

LeetCode 149. Given an array of points where points[i] =...

Evaluate Reverse Polish Notation Problem

LeetCode 150. Evaluate the value of an arithmetic expression in...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Gray Code Problem

LeetCode 89. Given an integer n, return any valid n-bit...

Unique Paths Problem

LeetCode 62. A robot is located at the top-left corner...

Unique Paths II Problem

LeetCode 63. A robot is located at the top-left corner...

Plus One Problem

LeetCode 66. You are given a large integer represented as...

Climbing Stairs Problem

LeetCode 70. You are climbing a staircase. It takes n...

Permutation Sequence Problem

LeetCode 60. Given n and k, return the kth permutation...

Rotate Image Problem

LeetCode 48. Determine if a 9 x 9 Sudoku board...

Pow(x,n) Problem

LeetCode 50. Determine if a 9 x 9 Sudoku board...

Palindrome Number Problem

LeetCode 9. Given an integer x, return true if x...

Multiply Strings Problem

LeetCode 43. Given two non-negative integers num1 and num2 represented...

Integer to Roman Problem

LeetCode 12. Given an integer, convert it to a roman...

Divide Two Integers Problem

LeetCode 29. Write the code that will take a string...

Roman to Integer Problem

LeetCode 13. Given a roman numeral, convert it to an...

Reverse Integer Problem

LeetCode 7. Given a signed 32-bit integer x, return x...

Tag Recursion

All Possible Full Binary Trees Problem

LeetCode 894. Given an integer n, return a list of...

Special Binary String Problem

LeetCode 761. Special binary strings are binary strings with the...

Parse Lisp Expression Problem

LeetCode 736. You are given a string expression representing a...

K-Th Symbol In Grammar Problem

LeetCode 779. We build a table of n rows (1-indexed)....

Basic Calculator IV Problem

LeetCode 770. Given an expression such as expression = “e...

Predict The Winner Problem

LeetCode 486. You are given an integer array nums. Two...

Fibonacci Number Problem

LeetCode 509. The Fibonacci numbers, commonly denoted F(n) form a...

Remove Linked List Elements Problem

LeetCode 203. Given the head of a linked list and...

Power Of Two Problem

LeetCode 231. Given an integer n, return true if it...

Power Of Three Problem

LeetCode 326. Given an integer n, return true if it...

Power Of Four Problem

LeetCode 342. Given an integer n, return true if it...

Number Of Digit One Problem

LeetCode 233. Given an integer n, count the total number...

Integer To English Words Problem

LeetCode 273. Convert a non-negative integer num to its English...

Elimination Game Problem

LeetCode 390. You have a list arr of all integers...

Different Ways To Add Parentheses Problem

LeetCode 241. Given a string expression of numbers and operators,...

Decode String Problem

LeetCode 394. Given an encoded string, return its decoded string....

Basic Calculator Problem

LeetCode 224. Given a string s representing a valid expression,...

Reorder List Problem

LeetCode 143. You are given the head of a singly...

Permutation Sequence Problem

LeetCode 60. Given n and k, return the kth permutation...

Wildcard Matching Problem

LeetCode 44. Write the code that will take a string...

Reverse Nodes in k-Group Problem

LeetCode 25. Given a linked list, reverse the nodes of...

Regular Expression Matching Problem

LeetCode 10. Given an input string s and a pattern...

Pow(x,n) Problem

LeetCode 50. Determine if a 9 x 9 Sudoku board...

Swap Nodes in Pairs Problem

LeetCode 24. Given a linked list, swap every two adjacent...


Tag Stack

Validate Stack Sequences Problem

LeetCode 946. Given two integer arrays pushed and popped each...

Sum Of Subarray Minimums Problem

LeetCode 907. Given an array of integers arr, find the...

Stamping The Sequence Problem

LeetCode 936. You are given two strings stamp and target....

Score Of Parentheses Problem

LeetCode 856. Given a balanced parentheses string s, return the...

Online Stock Span Problem

LeetCode 901. Design an algorithm that collects daily price quotes...

Odd Even Jump Problem

LeetCode 975. You are given an integer array arr. From...

Minimum Add To Make Parentheses Valid Problem

LeetCode 921. A parentheses string is valid if and only...

Maximum Width Ramp Problem

LeetCode 962. A ramp in an integer array nums is...

Maximum Frequency Stack Problem

LeetCode 895. Design a stack-like data structure to push elements...

Increasing Order Search Tree Problem

LeetCode 897. Given the root of a binary search tree,...

Decoded String At Index Problem

LeetCode 880. You are given an encoded string s. To...

Car Fleet Problem

LeetCode 853. There are n cars going to the same...

Backspace String Compare Problem

LeetCode 844. Given two strings s and t, return true...

Valid Parenthesis String Problem

LeetCode 678. Given a string s containing only three types...

Parse Lisp Expression Problem

LeetCode 736. You are given a string expression representing a...

Exclusive Time Of Functions Problem

LeetCode 636. On a single-threaded CPU, we execute a program...

Number Of Atoms Problem

LeetCode 726. Given a string formula representing a chemical formula,return...

Max Chunks To Make Sorted Problem

LeetCode 769. You are given an integer array arr of...

Max Chunks To Make Sorted II Problem

LeetCode 768. You are given an integer array arr.

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Daily Temperatures Problem

LeetCode 739. Given an array of integers temperatures represents the...

Basic Calculator IV Problem

LeetCode 770. Given an expression such as expression = “e...

Baseball Game Problem

LeetCode 682. You are keeping score for a baseball game...

Asteroid Collision Problem

LeetCode 735. We are given an array asteroids of integers...

Tag Validator Problem

LeetCode 591. Given a string representing a code snippet, implement...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Remove K Digits Problem

LeetCode 402. Given string num representing a non-negative integer num,...

Next Greater Element II Problem

LeetCode 503. Given a circular integer array nums (i.e., the...

Next Greater Element I Problem

LeetCode 496. The next greater element of some element x...

N-Ary Tree Preorder Traversal Problem

LeetCode 589. Given the root of an n-ary tree, return...

N-Ary Tree Postorder Traversal Problem

LeetCode 590. Given the root of an n-ary tree, return...

Add Two Numbers II Problem

LeetCode 445. You are given two non-empty linked lists representing...

132 Pattern Problem

LeetCode 456. Given an arrayof n integers nums, a 132...

Verify Preorder Serialization Of A Binary Tree Problem

LeetCode 331. One way to serialize a binary tree is...

Remove Duplicate Letters Problem

LeetCode 316. Given a string s, remove duplicate letters so...

Mini Parser Problem

LeetCode 385. Given a string s represents the serialization of...

Longest Absolute File Path Problem

LeetCode 388. Suppose we have a file system that stores...

Implement Stack Using Queues Problem

LeetCode 225. Implement a last-in-first-out (LIFO) stack using only two...

Implement Queue Using Stacks Problem

LeetCode 232. Implement a first in first out (FIFO) queue...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

Decode String Problem

LeetCode 394. Given an encoded string, return its decoded string....

Create Maximum Number Problem

LeetCode 321. You are given two integer arrays nums1 and...

Basic Calculator Problem

LeetCode 224. Given a string s representing a valid expression,...

Basic Calculator II Problem

LeetCode 227. Given a string s which represents an expression,...

Min Stack Problem

LeetCode 155. Design a stack that supports push, pop, top,...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Reorder List Problem

LeetCode 143. You are given the head of a singly...

Evaluate Reverse Polish Notation Problem

LeetCode 150. Evaluate the value of an arithmetic expression in...

Binary Tree Preorder Traversal Problem

LeetCode 144. Given the root of a binary tree, return...

Binary Tree Postorder Traversal Problem

LeetCode 145. Given the root of abinary tree, return the...

Flatten Binary Tree To Linked List Problem

LeetCode 114. Given the root of a binary tree, flatten...

Maximal Rectangle Problem

LeetCode 85. Given a rows x cols binary matrix filled...

Largest Rectangle in Histogram Problem

LeetCode 84. Given an array of integers heights representing the...

Binary Tree Inorder Traversal Problem

LeetCode 94. Given an m x n grid of characters...

Simplify Path Problem

LeetCode 71. Given a string path, which is an absolute...

Trapping Rain Water Problem

LeetCode 42. Given n non-negative integers representing an elevation map...

Valid Parentheses Problem

LeetCode 20. Given a string s containing just the characters...

Tag Sorting

Sum Of Subsequence Widths Problem

LeetCode 891. The width of a sequence is the difference...

Squares Of A Sorted Array Problem

LeetCode 977. Given an integer array nums sorted in non-decreasing...

Sort Array By Parity Problem

LeetCode 905. Given an integer array nums, move all the...

Sort Array By Parity II Problem

LeetCode 922. Given an array of integers nums, half of...

Sort An Array Problem

LeetCode 912. Given an array of integers nums, sort the...

Smallest Range II Problem

LeetCode 910. You are given an integer array nums and...

Reveal Cards In Increasing Order Problem

LeetCode 950. You are given an integer array deck. There...

Reordered Power Of 2 Problem

LeetCode 869. You are given an integer n. We reorder...

Reorder Data In Log Files Problem

LeetCode 937. You are given an array of logs. Each...

Pancake Sorting Problem

LeetCode 969. Given an array of integers arr, sort the...

Orderly Queue Problem

LeetCode 899. You are given a string s and an...

Most Profit Assigning Work Problem

LeetCode 826. You have n jobs and m workers. You...

Minimum Increment To Make Array Unique Problem

LeetCode 945. You are given an integer array nums. In...

Minimum Cost To Hire K Workers Problem

LeetCode 857. There are n workers. You are given two...

Minimum Area Rectangle Problem

LeetCode 939. You are given an array of points in...

Largest Perimeter Triangle Problem

LeetCode 976. Given an integer array nums, return the largest...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Hand Of Straights Problem

LeetCode 846. Alice has some number of cards and she...

Friends Of Appropriate Ages Problem

LeetCode 825. There are n persons on a social media...

Find And Replace In String Problem

LeetCode 833. You are given a 0-indexed string s that...

Fair Candy Swap Problem

LeetCode 888. Alice and Bob have a different total number...

Car Fleet Problem

LeetCode 853. There are n cars going to the same...

Boats To Save People Problem

LeetCode 881. You are given an array people where people[i]...

Bag Of Tokens Problem

LeetCode 948. You have an initial power of power, an...

Array Of Doubled Pairs Problem

LeetCode 954. Given an integer array of even length arr,...

Advantage Shuffle Problem

LeetCode 870. You are given two integer arrays nums1 and...

3Sum With Multiplicity Problem

LeetCode 923. Given an integer array arr, and an integer...

Valid Triangle Number Problem

LeetCode 611. Given an integer array nums, return the number...

Top K Frequent Words Problem

LeetCode 692. Given an array of strings words and an...

Task Scheduler Problem

LeetCode 621. Given a characters array tasks, representing the tasks...

Set Mismatch Problem

LeetCode 645. You have a set of integers s, which...

Set Intersection Size At Least Two Problem

LeetCode 757. You are given a 2D integer array intervals...

Reorganize String Problem

LeetCode 767. Given a string s, rearrange the characters of...

Random Pick With Blacklist Problem

LeetCode 710. You are given an integer n and an...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Number Of Matching Subsequences Problem

LeetCode 792. Given a string s and an array of...

Number Of Atoms Problem

LeetCode 726. Given a string formula representing a chemical formula,return...

Maximum Product Of Three Numbers Problem

LeetCode 628. Given an integer array nums, find three numbers...

Maximum Length Of Pair Chain Problem

LeetCode 646. You are given an array of n pairs...

Max Chunks To Make Sorted Problem

LeetCode 769. You are given an integer array arr of...

Max Chunks To Make Sorted II Problem

LeetCode 768. You are given an integer array arr.

Largest Number At Least Twice Of Others Problem

LeetCode 747. You are given an integer array nums where...

K-Th Smallest Prime Fraction Problem

LeetCode 786. You are given a sorted integer array arr...

Find K-Th Smallest Pair Distance Problem

LeetCode 719. The distance of a pair of integers a...

Find K Closest Elements Problem

LeetCode 658. Given a sorted integer array arr, two integers...

Custom Sort String Problem

LeetCode 791. You are given two strings order and s....

Third Maximum Number Problem

LeetCode 414. Given an integer array nums, return the third...

IPO Problem

LeetCode 502. Suppose LeetCode will start its IPO soon. In...

Sort Characters By Frequency Problem

LeetCode 451. Given a string s, sort it in decreasing...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Relative Ranks Problem

LeetCode 506. You are given an integer array score of...

Queue Reconstruction By Height Problem

LeetCode 406. You are given an array of people, people,...

Non-Overlapping Intervals Problem

LeetCode 435. Given an array of intervals intervals where intervals[i]...

Minimum Time Difference Problem

LeetCode 539. Given a list of 24-hour clock time points...

Minimum Number Of Arrows To Burst Balloons Problem

LeetCode 452. There are some spherical balloons taped onto a...

Minimum Moves To Equal Array Elements II Problem

LeetCode 462. Given an integer array nums of size n,...

Longest Uncommon Subsequence II Problem

LeetCode 522. Given an array of strings strs, return the...

Longest Harmonious Subsequence Problem

LeetCode 594. We define a harmonious array as an array...

K-Diff Pairs In An Array Problem

LeetCode 532. Given an array of integers nums and an...

Heaters Problem

LeetCode 475. Winter is coming! During the contest, your first...

Find Right Interval Problem

LeetCode 436. You are given an array of intervals, where...

Assign Cookies Problem

LeetCode 455. Assume you are an awesome parent and want...

Array Partition I Problem

LeetCode 561. Given an integer array nums of 2n integers,...

Valid Anagram Problem

LeetCode 242. Given two strings s and t, return true...

Top K Frequent Elements Problem

LeetCode 347. Given an integer array nums and an integer...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Majority Element II Problem

LeetCode 229. Given an integer array of size n, find...

Largest Divisible Subset Problem

LeetCode 368. Given a set of distinct positive integers nums,...

Kth Largest Element In An Array Problem

LeetCode 215. Given an integer array nums and an integer...

Intersection Of Two Arrays II Problem

LeetCode 350. Given two integer arrays nums1 and nums2, return...

H-Index Problem

LeetCode 274. Given an array of integers citations where citations[i]...

Find The Difference Problem

LeetCode 389. You are given two strings s and t....

Find Median From Data Stream Problem

LeetCode 295. The median is the middle value in an...

Contains Duplicate Problem

LeetCode 217. Given an integer array nums, return true if...

Contains Duplicate III Problem

LeetCode 220. Given an integer array nums and two integers...

Maximum Gap Problem

LeetCode 164. Given an integer array nums, return the maximum...

Majority Element Problem

LeetCode 169. Given an array nums of size n, return...

Largest Number Problem

LeetCode 179. Given a list of non-negative integers nums, arrange...

Sort List Problem

LeetCode 148. Given the head of a linked list, return...

Insertion Sort List Problem

LeetCode 147. Given the head of a singly linked list,...

Merge Sorted Array Problem

LeetCode 88. You are given two integer arrays nums1 and...

Group Anagrams Problem

LeetCode 49. Given an array of strings strs, group the...

3Sum Closest Problem

LeetCode 16. Given an integer array nums of length n...

Tag Bit Manipulation

Unique Paths III Problem

LeetCode 980. You are given an m x n integer...

Triples With Bitwise And Equal To Zero Problem

LeetCode 982. Given an integer array nums, return the number...

Split Array With Same Average Problem

LeetCode 805. You are given an integer array nums.

Shortest Path Visiting All Nodes Problem

LeetCode 847. You have an undirected, connected graph of n...

Score After Flipping Matrix Problem

LeetCode 861. You are given an m x n binary...

Prison Cells After N Days Problem

LeetCode 957. There are 8 prison cells in a row...

Number Of Squareful Arrays Problem

LeetCode 996. An array is squareful if the sum of...

Find The Shortest Superstring Problem

LeetCode 943. Given an array of strings words, return the...

Chalkboard Xor Game Problem

LeetCode 810. You are given an array of integers nums...

Bitwise ORs Of Subarrays Problem

LeetCode 898. We have an array arr of non-negative integers....

Binary Gap Problem

LeetCode 868. Given a positive integer n, find and return...

Transform To Chessboard Problem

LeetCode 782. You are given an n x n binary...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Set Mismatch Problem

LeetCode 645. You have a set of integers s, which...

Pyramid Transition Matrix Problem

LeetCode 756. You are stacking blocks to form a pyramid....

K-Th Symbol In Grammar Problem

LeetCode 779. We build a table of n rows (1-indexed)....

Prime Number Of Set Bits In Binary Representation Problem

LeetCode 762. Given two integers left and right, return the...

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Letter Case Permutation Problem

LeetCode 784. Given a string s, we can transform every...

Bulb Switcher II Problem

LeetCode 672. There is a room with n bulbs labeled...

Binary Number With Alternating Bits Problem

LeetCode 693. Given a positive integer, check whether it has...

Total Hamming Distance Problem

LeetCode 477. The Hamming distance between two integers is the...

Number Complement Problem

LeetCode 476. The complement of an integer is the integer...

Matchsticks To Square Problem

LeetCode 473. You are given an integer array matchsticks where...

Increasing Subsequences Problem

LeetCode 491. Given an integer array nums, return all the...

Hamming Distance Problem

LeetCode 461. The Hamming distance between two integers is the...

Convert A Number To Hexadecimal Problem

LeetCode 405. Given an integer num, return a string representing...

UTF-8 Validation Problem

LeetCode 393. Given an integer array data representing the data,...

Can I Win Problem

LeetCode 464. In the “100 game” two players take turns...

Binary Watch Problem

LeetCode 401. A binary watch has 4 LEDs on the...

Sum Of Two Integers Problem

LeetCode 371. Given two integers a and b, return the...

Single Number III Problem

LeetCode 260. Given an integer array nums, in which exactly...

Power Of Two Problem

LeetCode 231. Given an integer n, return true if it...

Power Of Four Problem

LeetCode 342. Given an integer n, return true if it...

Missing Number Problem

LeetCode 268. Given an array nums containing n distinct numbers...

Maximum Product Of Word Lengths Problem

LeetCode 318. Given a string array words, return the maximum...

Integer Replacement Problem

LeetCode 397. Given a positive integer n,you can apply one...

Find The Duplicate Number Problem

LeetCode 287. Given an array of integers nums containingn +...

Find The Difference Problem

LeetCode 389. You are given two strings s and t....

Counting Bits Problem

LeetCode 338. Given an integer n, return an array ans...

Bitwise And Of Numbers Range Problem

LeetCode 201. Given two integers left and right that represent...

Reverse Bits Problem

LeetCode 190. Reverse bits of a given 32 bits unsigned...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...

Number Of 1 Bits Problem

LeetCode 191. Write a function that takes an unsigned integer...

Single Number Problem

LeetCode 136. Given a non-empty array of integers nums, every...

Single Number II Problem

LeetCode 137. Given an integer array nums whereevery element appears...

Subsets II Problem

LeetCode 90. Given an integer array nums that may contain...

Gray Code Problem

LeetCode 89. Given an integer n, return any valid n-bit...

Divide Two Integers Problem

LeetCode 29. Write the code that will take a string...

Tag Stack Leetcode

Longest Valid Parentheses Problem

LeetCode 32. Given a string containing just the characters ‘(‘...


Tag Divide and Conquer

Sort An Array Problem

LeetCode 912. Given an array of integers nums, sort the...

Maximum Sum Circular Subarray Problem

LeetCode 918. Given a circular integer array nums of length...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Construct Binary Tree From Preorder And Postorder Traversal Problem

LeetCode 889. Given two integer arrays, preorder and postorder where...

Beautiful Array Problem

LeetCode 932. Given the integer n, return any beautiful array...

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Reverse Pairs Problem

LeetCode 493. Given an integer array nums, return the number...

Construct Quad Tree Problem

LeetCode 427. Given a n * n matrix grid of...

Top K Frequent Elements Problem

LeetCode 347. Given an integer array nums and an integer...

Super Pow Problem

LeetCode 372. Your task is to calculate a^b mod 1337...

Search A 2D Matrix II Problem

LeetCode 240. Write an efficient algorithm that searches for a...

Kth Largest Element In An Array Problem

LeetCode 215. Given an integer array nums and an integer...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Reverse Bits Problem

LeetCode 190. Reverse bits of a given 32 bits unsigned...

Majority Element Problem

LeetCode 169. Given an array nums of size n, return...

Sort List Problem

LeetCode 148. Given the head of a linked list, return...

Convert Sorted Array to Binary Search Tree Problem

LeetCode 108. Given an integer array nums where the elements...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Maximum Subarray Problem

LeetCode 53. Given an integer array nums, find the contiguous...

Tag Matrix

Unique Paths III Problem

LeetCode 980. You are given an m x n integer...

Transpose Matrix Problem

LeetCode 867. Given a 2D integer array matrix, return the...

Surface Area Of 3D Shapes Problem

LeetCode 892. You are given an n x n grid...

Spiral Matrix III Problem

LeetCode 885. You start at the cell (rStart, cStart) of...

Snakes And Ladders Problem

LeetCode 909. You are given an n x n integer...

Shortest Bridge Problem

LeetCode 934. You are given an n x n binary...

Score After Flipping Matrix Problem

LeetCode 861. You are given an m x n binary...

Rotting Oranges Problem

LeetCode 994. You are given an m x n grid...

Projection Area Of 3D Shapes Problem

LeetCode 883. You are given an n x n grid...

Minimum Falling Path Sum Problem

LeetCode 931. Given an n x n array of integers...

Minimize Malware Spread Problem

LeetCode 924. You are given a network of n nodes...

Minimize Malware Spread II Problem

LeetCode 928. You are given a network of n nodes...

Max Increase To Keep City Skyline Problem

LeetCode 807. There is a city composed of n x...

Making A Large Island Problem

LeetCode 827. You are given an n x n binary...

Magic Squares In Grid Problem

LeetCode 840. A 3 x 3 magic square is a...

Image Overlap Problem

LeetCode 835. You are given two images, img1 and img2,...

Flipping An Image Problem

LeetCode 832. Given an n x n binary matrix image,...

Bricks Falling When Hit Problem

LeetCode 803. You are given an m x n binary...

Available Captures For Rook Problem

LeetCode 999. On an 8 x 8 chessboard, there is...

Transform To Chessboard Problem

LeetCode 782. You are given an n x n binary...

Toeplitz Matrix Problem

LeetCode 766. Given an m x n matrix, returntrueif the...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Sliding Puzzle Problem

LeetCode 773. On an 2 x 3 board, there are...

Cherry Pickup Problem

LeetCode 741. You are given an n x n grid...

Image Smoother Problem

LeetCode 661. An image smoother is a filter of the...

Flood Fill Problem

LeetCode 733. An image is represented by an m x...

Cut Off Trees For Golf Event Problem

LeetCode 675. You are asked to cut off all the...

Max Area Of Island Problem

LeetCode 695. You are given an m x n binary...

Contain Virus Problem

LeetCode 749. A virus is spreading rapidly, and your task...

Trapping Rain Water II Problem

LeetCode 407. Given an m x n integer matrix heightMap...

Pacific Atlantic Water Flow Problem

LeetCode 417. There is an m x n rectangular island...

Reshape The Matrix Problem

LeetCode 566. In MATLAB, there is a handy function called...

Minesweeper Problem

LeetCode 529. Let’s play the minesweeper game!

Island Perimeter Problem

LeetCode 463. You are given row x col grid representing...

Diagonal Traverse Problem

LeetCode 498. Given an m x n matrix mat, return...

Construct Quad Tree Problem

LeetCode 427. Given a n * n matrix grid of...

Battleships In A Board Problem

LeetCode 419. Given an m x n matrix board where...

01 Matrix Problem

LeetCode 542. Given an m x n binary matrix mat,...

Search A 2D Matrix II Problem

LeetCode 240. Write an efficient algorithm that searches for a...

Range Sum Query 2D - Immutable Problem

LeetCode 304. Given a 2D matrix matrix, handle multiple queries...

Maximal Square Problem

LeetCode 221. Given an m x n binary matrix filled...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Game Of Life Problem

LeetCode 289. The Game of Life, also known simply as...

Dungeon Game Problem

LeetCode 174. The demons had captured the princess and imprisoned...

Surrounded Regions Problem

LeetCode 130. Given an m x n matrix board containing...

Spiral Matrix Problem

LeetCode 54. Given an m x n matrix, return all...

Spiral Matrix II Problem

LeetCode 59. Given a positive integer n, generate an n...

Tag Git Commit

How to Modify Existing Unpushed Commit Messages

Short answers to the question how to modify existing unpushed...

Tag Git Revert

How to Revert a Git Repository to a Previous Commit

Short answers to the question how to revert a git...


Tag Git Pull

What is the Difference Between Git Pull and Git Fetch

Short answers to the question what is the difference between...

Tag Hash Table String

Minimum Window Substring Problem

LeetCode 76. Given two strings s and t of lengths...

Vertical Order Traversal Of A Binary Tree Problem

LeetCode 987. Given the root of a binary tree, calculate...

Univalued Binary Tree Problem

LeetCode 965. A binary tree is uni-valued if every node...

Sum Of Distances In Tree Problem

LeetCode 834. There is an undirected connected tree with n...

Smallest Subtree With All The Deepest Nodes Problem

LeetCode 865. Given the root of a binary tree, the...

Smallest String Starting From Leaf Problem

LeetCode 988. You are given the root of a binary...

Similar String Groups Problem

LeetCode 839. Two strings Xand Yare similar if we can...

Shortest Bridge Problem

LeetCode 934. You are given an n x n binary...

Range Sum Of BST Problem

LeetCode 938. Given the root node of a binary search...

Minimize Malware Spread Problem

LeetCode 924. You are given a network of n nodes...

Minimize Malware Spread II Problem

LeetCode 928. You are given a network of n nodes...

Making A Large Island Problem

LeetCode 827. You are given an n x n binary...

Loud And Rich Problem

LeetCode 851. There is a group of n people labeled...

Leaf-Similar Trees Problem

LeetCode 872. Consider all the leaves of a binary tree,...

Keys And Rooms Problem

LeetCode 841. There are n rooms labeled from 0 to...

Increasing Order Search Tree Problem

LeetCode 897. Given the root of a binary search tree,...

Flip Equivalent Binary Trees Problem

LeetCode 951. For a binary tree T, we can define...

Distribute Coins In Binary Tree Problem

LeetCode 979. You are given the root of a binary...

Cousins In Binary Tree Problem

LeetCode 993. Given the root of a binary tree with...

Binary Tree Pruning Problem

LeetCode 814. Given the root of a binary tree, return...

Binary Tree Cameras Problem

LeetCode 968. You are given the root of a binary...

All Nodes Distance K In Binary Tree Problem

LeetCode 863. Given the root of a binary tree, the...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Redundant Connection Problem

LeetCode 684. In this problem, a tree is an undirected...

Pyramid Transition Matrix Problem

LeetCode 756. You are stacking blocks to form a pyramid....

Network Delay Time Problem

LeetCode 743. You are given a network of n nodes,...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Trim A Binary Search Tree Problem

LeetCode 669. Given the root of a binary search tree...

Second Minimum Node In A Binary Tree Problem

LeetCode 671. Given a non-empty special binary tree consisting of...

Print Binary Tree Problem

LeetCode 655. Given the root of a binary tree, construct...

Minimum Distance Between BST Nodes Problem

LeetCode 783. Given the root of a Binary Search Tree...

Merge Two Binary Trees Problem

LeetCode 617. You are given two binary trees root1 and...

Maximum Width Of Binary Tree Problem

LeetCode 662. Given the root of a binary tree, return...

Longest Univalue Path Problem

LeetCode 687. Given the root of a binary tree, return...

Is Graph Bipartite? Problem

LeetCode 785. There is an undirected graph with n nodes,...

Flood Fill Problem

LeetCode 733. An image is represented by an m x...

Max Area Of Island Problem

LeetCode 695. You are given an m x n binary...

Find Duplicate Subtrees Problem

LeetCode 652. Given the rootof a binary tree, return all...

Employee Importance Problem

LeetCode 690. You have a data structure of employee information,...

Cracking The Safe Problem

LeetCode 753. There is a safe protected by a password....

Couples Holding Hands Problem

LeetCode 765. There are n couples sitting in 2n seats...

Contain Virus Problem

LeetCode 749. A virus is spreading rapidly, and your task...

Construct String From Binary Tree Problem

LeetCode 606. Given the root of a binary tree, construct...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

Bulb Switcher II Problem

LeetCode 672. There is a room with n bulbs labeled...

Average Of Levels In Binary Tree Problem

LeetCode 637. Given the root of a binary tree, return...

All Paths From Source To Target Problem

LeetCode 797. Given a directed acyclic graph (DAG) of n...

Add One Row To Tree Problem

LeetCode 623. Given the root of a binary tree and...

Accounts Merge Problem

LeetCode 721. Given a list of accounts where each element...

Pacific Atlantic Water Flow Problem

LeetCode 417. There is an m x n rectangular island...

Freedom Trail Problem

LeetCode 514. In the video game Fallout 4, the quest...

Sum Of Left Leaves Problem

LeetCode 404. Given the root of a binary tree, return...

Subtree Of Another Tree Problem

LeetCode 572. Given the roots of two binary trees root...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Path Sum III Problem

LeetCode 437. Given the root of a binary tree and...

Number Of Provinces Problem

LeetCode 547. There are n cities. Some of them are...

N-Ary Tree Preorder Traversal Problem

LeetCode 589. Given the root of an n-ary tree, return...

N-Ary Tree Postorder Traversal Problem

LeetCode 590. Given the root of an n-ary tree, return...

Most Frequent Subtree Sum Problem

LeetCode 508. Given the root of a binary tree, return...

Minimum Absolute Difference In BST Problem

LeetCode 530. Given the root of a Binary Search Tree...

Minesweeper Problem

LeetCode 529. Let’s play the minesweeper game!

Maximum Depth Of N-Ary Tree Problem

LeetCode 559. Given a n-ary tree, find its maximum depth....

Island Perimeter Problem

LeetCode 463. You are given row x col grid representing...

Find Mode In Binary Search Tree Problem

LeetCode 501. Given the root of a binary search tree...

Find Largest Value In Each Tree Row Problem

LeetCode 515. Given the root of a binary tree, return...

Find Bottom Left Tree Value Problem

LeetCode 513. Given the root of a binary tree, return...

Convert BST To Greater Tree Problem

LeetCode 538. Given the root of a Binary Search Tree...

Water And Jug Problem Problem

LeetCode 365. You are given two jugs with capacities jug1Capacity...

Can I Win Problem

LeetCode 464. In the “100 game” two players take turns...

Binary Tree Tilt Problem

LeetCode 563. Given the root of a binary tree, return...

Battleships In A Board Problem

LeetCode 419. Given an m x n matrix board where...

Array Nesting Problem

LeetCode 565. You are given an integer array nums of...

Minimum Height Trees Problem

LeetCode 310. A tree is an undirected graph in which...

Mini Parser Problem

LeetCode 385. Given a string s represents the serialization of...

Lowest Common Ancestor Of A Binary Tree Problem

LeetCode 236. Given a binary tree, find the lowest common...

Lowest Common Ancestor Of A Binary Search Tree Problem

LeetCode 235. Given a binary search tree (BST), find the...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Longest Absolute File Path Problem

LeetCode 388. Suppose we have a file system that stores...

Lexicographical Numbers Problem

LeetCode 386. Given an integer n, return all the numbers...

Kth Smallest Element In A BST Problem

LeetCode 230. Given the root of a binary search tree,...

Invert Binary Tree Problem

LeetCode 226. Given the root of a binary tree, invert...

House Robber III Problem

LeetCode 337. The thief has found himself a new place...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Design Add And Search Words Data Structure Problem

LeetCode 211. Design a data structure that supports adding new...

Course Schedule Problem

LeetCode 207. There are a total of numCourses courses you...

Course Schedule II Problem

LeetCode 210. There are a total of numCourses courses you...

Count Complete Tree Nodes Problem

LeetCode 222. Given the root of a complete binary tree,...

Binary Tree Paths Problem

LeetCode 257. Given the root of a binary tree, return...

Binary Tree Right Side View Problem

LeetCode 199. Given the root of a binary tree, imagine...

Clone Graph Problem

LeetCode 133. Given a reference of a node in a...

Binary Tree Preorder Traversal Problem

LeetCode 144. Given the root of a binary tree, return...

Binary Tree Postorder Traversal Problem

LeetCode 145. Given the root of abinary tree, return the...

Surrounded Regions Problem

LeetCode 130. Given an m x n matrix board containing...

Sum Root To Leaf Numbers Problem

LeetCode 129. You are given the root of a binary...

Populating Next Right Pointers In Each Node Problem

LeetCode 116. You are given a perfect binary tree where...

Populating Next Right Pointers In Each Node II Problem

LeetCode 117. Given a binary tree, populate each next pointer...

Path Sum Problem

LeetCode 112. Given the root of a binary tree and...

Path Sum II Problem

LeetCode 113. Given the root of a binary tree and...

Minimum Depth Of Binary Tree Problem

LeetCode 111. Given a binary tree, find its minimum depth....

Flatten Binary Tree To Linked List Problem

LeetCode 114. Given the root of a binary tree, flatten...

Balanced Binary Tree Problem

LeetCode 110. Given a binary tree, determine if it is...

Symmetric Tree Problem

LeetCode 101. Given the root of a binary tree, check...

Maximum Depth of Binary Tree Problem

LeetCode 104. Given the root of a binary tree, return...

Construct Binary Tree From Inorder And Postorder Traversal Problem

LeetCode 106. Given two integer arrays inorder and postorder where...

Validate Binary Search Tree Problem

LeetCode 98. Given the root of a binary tree, determine...

Same Tree Problem

LeetCode 100. Given the roots of two binary trees p...

Recover Binary Search Tree Problem

LeetCode 99. You are given the root of a binary...

Binary Tree Inorder Traversal Problem

LeetCode 94. Given an m x n grid of characters...

Tag Binary Tree

Vertical Order Traversal Of A Binary Tree Problem

LeetCode 987. Given the root of a binary tree, calculate...

Univalued Binary Tree Problem

LeetCode 965. A binary tree is uni-valued if every node...

Smallest Subtree With All The Deepest Nodes Problem

LeetCode 865. Given the root of a binary tree, the...

Smallest String Starting From Leaf Problem

LeetCode 988. You are given the root of a binary...

Range Sum Of BST Problem

LeetCode 938. Given the root node of a binary search...

Maximum Binary Tree II Problem

LeetCode 998. A maximum tree is a tree where every...

Leaf-Similar Trees Problem

LeetCode 872. Consider all the leaves of a binary tree,...

Flip Equivalent Binary Trees Problem

LeetCode 951. For a binary tree T, we can define...

Distribute Coins In Binary Tree Problem

LeetCode 979. You are given the root of a binary...

Cousins In Binary Tree Problem

LeetCode 993. Given the root of a binary tree with...

Construct Binary Tree From Preorder And Postorder Traversal Problem

LeetCode 889. Given two integer arrays, preorder and postorder where...

Complete Binary Tree Inserter Problem

LeetCode 919. A complete binary tree is a binary tree...

Check Completeness Of A Binary Tree Problem

LeetCode 958. Given the root of a binary tree, determine...

Binary Tree Pruning Problem

LeetCode 814. Given the root of a binary tree, return...

Binary Tree Cameras Problem

LeetCode 968. You are given the root of a binary...

All Possible Full Binary Trees Problem

LeetCode 894. Given an integer n, return a list of...

All Nodes Distance K In Binary Tree Problem

LeetCode 863. Given the root of a binary tree, the...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Trim A Binary Search Tree Problem

LeetCode 669. Given the root of a binary search tree...

Second Minimum Node In A Binary Tree Problem

LeetCode 671. Given a non-empty special binary tree consisting of...

Search In A Binary Search Tree Problem

LeetCode 700. You are given the root of a binary...

Print Binary Tree Problem

LeetCode 655. Given the root of a binary tree, construct...

Minimum Distance Between BST Nodes Problem

LeetCode 783. Given the root of a Binary Search Tree...

Merge Two Binary Trees Problem

LeetCode 617. You are given two binary trees root1 and...

Maximum Width Of Binary Tree Problem

LeetCode 662. Given the root of a binary tree, return...

Longest Univalue Path Problem

LeetCode 687. Given the root of a binary tree, return...

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

Find Duplicate Subtrees Problem

LeetCode 652. Given the rootof a binary tree, return all...

Construct String From Binary Tree Problem

LeetCode 606. Given the root of a binary tree, construct...

Average Of Levels In Binary Tree Problem

LeetCode 637. Given the root of a binary tree, return...

Add One Row To Tree Problem

LeetCode 623. Given the root of a binary tree and...

Sum Of Left Leaves Problem

LeetCode 404. Given the root of a binary tree, return...

Subtree Of Another Tree Problem

LeetCode 572. Given the roots of two binary trees root...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Path Sum III Problem

LeetCode 437. Given the root of a binary tree and...

Minimum Absolute Difference In BST Problem

LeetCode 530. Given the root of a Binary Search Tree...

Find Mode In Binary Search Tree Problem

LeetCode 501. Given the root of a binary search tree...

Find Largest Value In Each Tree Row Problem

LeetCode 515. Given the root of a binary tree, return...

Find Bottom Left Tree Value Problem

LeetCode 513. Given the root of a binary tree, return...

Delete Node In A BST Problem

LeetCode 450. Given a root node reference of a BST...

Convert BST To Greater Tree Problem

LeetCode 538. Given the root of a Binary Search Tree...

Binary Tree Tilt Problem

LeetCode 563. Given the root of a binary tree, return...

Verify Preorder Serialization Of A Binary Tree Problem

LeetCode 331. One way to serialize a binary tree is...

Lowest Common Ancestor Of A Binary Tree Problem

LeetCode 236. Given a binary tree, find the lowest common...

Lowest Common Ancestor Of A Binary Search Tree Problem

LeetCode 235. Given a binary search tree (BST), find the...

Kth Smallest Element In A BST Problem

LeetCode 230. Given the root of a binary search tree,...

Invert Binary Tree Problem

LeetCode 226. Given the root of a binary tree, invert...

House Robber III Problem

LeetCode 337. The thief has found himself a new place...

Count Complete Tree Nodes Problem

LeetCode 222. Given the root of a complete binary tree,...

Binary Tree Paths Problem

LeetCode 257. Given the root of a binary tree, return...

Binary Tree Right Side View Problem

LeetCode 199. Given the root of a binary tree, imagine...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Binary Tree Preorder Traversal Problem

LeetCode 144. Given the root of a binary tree, return...

Binary Tree Postorder Traversal Problem

LeetCode 145. Given the root of abinary tree, return the...

Sum Root To Leaf Numbers Problem

LeetCode 129. You are given the root of a binary...

Populating Next Right Pointers In Each Node Problem

LeetCode 116. You are given a perfect binary tree where...

Populating Next Right Pointers In Each Node II Problem

LeetCode 117. Given a binary tree, populate each next pointer...

Path Sum Problem

LeetCode 112. Given the root of a binary tree and...

Path Sum II Problem

LeetCode 113. Given the root of a binary tree and...

Minimum Depth Of Binary Tree Problem

LeetCode 111. Given a binary tree, find its minimum depth....

Flatten Binary Tree To Linked List Problem

LeetCode 114. Given the root of a binary tree, flatten...

Balanced Binary Tree Problem

LeetCode 110. Given a binary tree, determine if it is...

Symmetric Tree Problem

LeetCode 101. Given the root of a binary tree, check...

Maximum Depth of Binary Tree Problem

LeetCode 104. Given the root of a binary tree, return...

Construct Binary Tree from Preorder and Inorder Traversal Problem

LeetCode 105. Given two integer arrays preorder and inorder where...

Construct Binary Tree From Inorder And Postorder Traversal Problem

LeetCode 106. Given two integer arrays inorder and postorder where...

Binary Tree Zigzag Level Order Traversal Problem

LeetCode 103. Given the root of a binary tree, return...

Binary Tree Level Order Traversal Problem

LeetCode 102. Given the root of a binary tree, return...

Binary Tree Level Order Traversal II Problem

LeetCode 107. Given the root of a binary tree, return...

Validate Binary Search Tree Problem

LeetCode 98. Given the root of a binary tree, determine...

Same Tree Problem

LeetCode 100. Given the roots of two binary trees p...

Recover Binary Search Tree Problem

LeetCode 99. You are given the root of a binary...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Binary Tree Inorder Traversal Problem

LeetCode 94. Given an m x n grid of characters...


Tag Binary Search Tree

Range Sum Of BST Problem

LeetCode 938. Given the root node of a binary search...

Increasing Order Search Tree Problem

LeetCode 897. Given the root of a binary search tree,...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Trim A Binary Search Tree Problem

LeetCode 669. Given the root of a binary search tree...

Search In A Binary Search Tree Problem

LeetCode 700. You are given the root of a binary...

Minimum Distance Between BST Nodes Problem

LeetCode 783. Given the root of a Binary Search Tree...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Minimum Absolute Difference In BST Problem

LeetCode 530. Given the root of a Binary Search Tree...

Find Mode In Binary Search Tree Problem

LeetCode 501. Given the root of a binary search tree...

Delete Node In A BST Problem

LeetCode 450. Given a root node reference of a BST...

Convert BST To Greater Tree Problem

LeetCode 538. Given the root of a Binary Search Tree...

Lowest Common Ancestor Of A Binary Search Tree Problem

LeetCode 235. Given a binary search tree (BST), find the...

Kth Smallest Element In A BST Problem

LeetCode 230. Given the root of a binary search tree,...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Convert Sorted Array to Binary Search Tree Problem

LeetCode 108. Given an integer array nums where the elements...

Validate Binary Search Tree Problem

LeetCode 98. Given the root of a binary tree, determine...

Same Tree Problem

LeetCode 100. Given the roots of two binary trees p...

Recover Binary Search Tree Problem

LeetCode 99. You are given the root of a binary...

Unique Binary Search Trees Problem

LeetCode 96. Given an integer n, return the number of...

Unique Binary Search Trees II Problem

LeetCode 95. Given an integer n, return all the structurally...

Vertical Order Traversal Of A Binary Tree Problem

LeetCode 987. Given the root of a binary tree, calculate...

Univalued Binary Tree Problem

LeetCode 965. A binary tree is uni-valued if every node...

Snakes And Ladders Problem

LeetCode 909. You are given an n x n integer...

Smallest Subtree With All The Deepest Nodes Problem

LeetCode 865. Given the root of a binary tree, the...

Similar String Groups Problem

LeetCode 839. Two strings Xand Yare similar if we can...

Shortest Path Visiting All Nodes Problem

LeetCode 847. You have an undirected, connected graph of n...

Shortest Bridge Problem

LeetCode 934. You are given an n x n binary...

Rotting Oranges Problem

LeetCode 994. You are given an m x n grid...

Numbers With Same Consecutive Differences Problem

LeetCode 967. Return all non-negative integers of length n such...

Minimize Malware Spread Problem

LeetCode 924. You are given a network of n nodes...

Minimize Malware Spread II Problem

LeetCode 928. You are given a network of n nodes...

Making A Large Island Problem

LeetCode 827. You are given an n x n binary...

Keys And Rooms Problem

LeetCode 841. There are n rooms labeled from 0 to...

K-Similar Strings Problem

LeetCode 854. Strings s1 and s2 are k-similar (for some...

Cousins In Binary Tree Problem

LeetCode 993. Given the root of a binary tree with...

Complete Binary Tree Inserter Problem

LeetCode 919. A complete binary tree is a binary tree...

Check Completeness Of A Binary Tree Problem

LeetCode 958. Given the root of a binary tree, determine...

Bus Routes Problem

LeetCode 815. You are given an array routes representing bus...

All Nodes Distance K In Binary Tree Problem

LeetCode 863. Given the root of a binary tree, the...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Sliding Puzzle Problem

LeetCode 773. On an 2 x 3 board, there are...

Redundant Connection Problem

LeetCode 684. In this problem, a tree is an undirected...

Pyramid Transition Matrix Problem

LeetCode 756. You are stacking blocks to form a pyramid....

Open The Lock Problem

LeetCode 752. You have a lock in front of you...

Network Delay Time Problem

LeetCode 743. You are given a network of n nodes,...

Two Sum IV - Input Is A BST Problem

LeetCode 653. Given the root of a Binary Search Tree...

Print Binary Tree Problem

LeetCode 655. Given the root of a binary tree, construct...

Minimum Distance Between BST Nodes Problem

LeetCode 783. Given the root of a Binary Search Tree...

Merge Two Binary Trees Problem

LeetCode 617. You are given two binary trees root1 and...

Maximum Width Of Binary Tree Problem

LeetCode 662. Given the root of a binary tree, return...

Is Graph Bipartite? Problem

LeetCode 785. There is an undirected graph with n nodes,...

Flood Fill Problem

LeetCode 733. An image is represented by an m x...

Cut Off Trees For Golf Event Problem

LeetCode 675. You are asked to cut off all the...

Max Area Of Island Problem

LeetCode 695. You are given an m x n binary...

Employee Importance Problem

LeetCode 690. You have a data structure of employee information,...

Couples Holding Hands Problem

LeetCode 765. There are n couples sitting in 2n seats...

Contain Virus Problem

LeetCode 749. A virus is spreading rapidly, and your task...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

Bulb Switcher II Problem

LeetCode 672. There is a room with n bulbs labeled...

Average Of Levels In Binary Tree Problem

LeetCode 637. Given the root of a binary tree, return...

All Paths From Source To Target Problem

LeetCode 797. Given a directed acyclic graph (DAG) of n...

Add One Row To Tree Problem

LeetCode 623. Given the root of a binary tree and...

Accounts Merge Problem

LeetCode 721. Given a list of accounts where each element...

Zuma Game Problem

LeetCode 488. You are playing a variation of the game...

Trapping Rain Water II Problem

LeetCode 407. Given an m x n integer matrix heightMap...

Pacific Atlantic Water Flow Problem

LeetCode 417. There is an m x n rectangular island...

Freedom Trail Problem

LeetCode 514. In the video game Fallout 4, the quest...

Sum Of Left Leaves Problem

LeetCode 404. Given the root of a binary tree, return...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

Number Of Provinces Problem

LeetCode 547. There are n cities. Some of them are...

N-Ary Tree Level Order Traversal Problem

LeetCode 429. Given an n-ary tree, return the level order...

Minimum Genetic Mutation Problem

LeetCode 433. A gene string can be represented by an...

Minimum Absolute Difference In BST Problem

LeetCode 530. Given the root of a Binary Search Tree...

Minesweeper Problem

LeetCode 529. Let’s play the minesweeper game!

Maximum Depth Of N-Ary Tree Problem

LeetCode 559. Given a n-ary tree, find its maximum depth....

Island Perimeter Problem

LeetCode 463. You are given row x col grid representing...

Find Largest Value In Each Tree Row Problem

LeetCode 515. Given the root of a binary tree, return...

Find Bottom Left Tree Value Problem

LeetCode 513. Given the root of a binary tree, return...

Water And Jug Problem Problem

LeetCode 365. You are given two jugs with capacities jug1Capacity...

01 Matrix Problem

LeetCode 542. Given an m x n binary matrix mat,...

Serialize And Deserialize Binary Tree Problem

LeetCode 297. Serialization is the process of converting a data...

Remove Invalid Parentheses Problem

LeetCode 301. Given a string s that contains parentheses and...

Perfect Squares Problem

LeetCode 279. Given an integer n, return the least number...

Minimum Height Trees Problem

LeetCode 310. A tree is an undirected graph in which...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Invert Binary Tree Problem

LeetCode 226. Given the root of a binary tree, invert...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Course Schedule Problem

LeetCode 207. There are a total of numCourses courses you...

Course Schedule II Problem

LeetCode 210. There are a total of numCourses courses you...

Coin Change Problem

LeetCode 322. You are given an integer array coins representing...

Binary Tree Right Side View Problem

LeetCode 199. Given the root of a binary tree, imagine...

Clone Graph Problem

LeetCode 133. Given a reference of a node in a...

Word Ladder Problem

LeetCode 127. Given two words, beginWord and endWord, and a...

Word Ladder II Problem

LeetCode 126. Given two words, beginWord and endWord, and a...

Surrounded Regions Problem

LeetCode 130. Given an m x n matrix board containing...

Populating Next Right Pointers In Each Node Problem

LeetCode 116. You are given a perfect binary tree where...

Populating Next Right Pointers In Each Node II Problem

LeetCode 117. Given a binary tree, populate each next pointer...

Minimum Depth Of Binary Tree Problem

LeetCode 111. Given a binary tree, find its minimum depth....

Symmetric Tree Problem

LeetCode 101. Given the root of a binary tree, check...

Maximum Depth of Binary Tree Problem

LeetCode 104. Given the root of a binary tree, return...

Construct Binary Tree From Inorder And Postorder Traversal Problem

LeetCode 106. Given two integer arrays inorder and postorder where...

Binary Tree Zigzag Level Order Traversal Problem

LeetCode 103. Given the root of a binary tree, return...

Binary Tree Level Order Traversal Problem

LeetCode 102. Given the root of a binary tree, return...

Binary Tree Level Order Traversal II Problem

LeetCode 107. Given the root of a binary tree, return...

Tag Binary Tree Leetcode

Convert Sorted Array to Binary Search Tree Problem

LeetCode 108. Given an integer array nums where the elements...

Tag Union Find

Similar String Groups Problem

LeetCode 839. Two strings Xand Yare similar if we can...

Satisfiability Of Equality Equations Problem

LeetCode 990. You are given an array of strings equations...

Minimize Malware Spread Problem

LeetCode 924. You are given a network of n nodes...

Minimize Malware Spread II Problem

LeetCode 928. You are given a network of n nodes...

Making A Large Island Problem

LeetCode 827. You are given an n x n binary...

Largest Component Size By Common Factor Problem

LeetCode 952. You are given an integer array of unique...

Bricks Falling When Hit Problem

LeetCode 803. You are given an m x n binary...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Redundant Connection Problem

LeetCode 684. In this problem, a tree is an undirected...

Is Graph Bipartite? Problem

LeetCode 785. There is an undirected graph with n nodes,...

Max Area Of Island Problem

LeetCode 695. You are given an m x n binary...

Couples Holding Hands Problem

LeetCode 765. There are n couples sitting in 2n seats...

Accounts Merge Problem

LeetCode 721. Given a list of accounts where each element...

Number Of Provinces Problem

LeetCode 547. There are n cities. Some of them are...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Surrounded Regions Problem

LeetCode 130. Given an m x n matrix board containing...

Longest Consecutive Sequence Problem

LeetCode 128. Given an unsorted array of integers nums, return...


Tag Graph

Sum Of Distances In Tree Problem

LeetCode 834. There is an undirected connected tree with n...

Shortest Path Visiting All Nodes Problem

LeetCode 847. You have an undirected, connected graph of n...

Satisfiability Of Equality Equations Problem

LeetCode 990. You are given an array of strings equations...

Reachable Nodes In Subdivided Graph Problem

LeetCode 882. You are given an undirected graph (the “original...

Loud And Rich Problem

LeetCode 851. There is a group of n people labeled...

Keys And Rooms Problem

LeetCode 841. There are n rooms labeled from 0 to...

Find The Town Judge Problem

LeetCode 997. In a town, there are n people labeled...

Cat And Mouse Problem

LeetCode 913. A game on an undirected graph is played...

Redundant Connection Problem

LeetCode 684. In this problem, a tree is an undirected...

Network Delay Time Problem

LeetCode 743. You are given a network of n nodes,...

Is Graph Bipartite? Problem

LeetCode 785. There is an undirected graph with n nodes,...

Cracking The Safe Problem

LeetCode 753. There is a safe protected by a password....

Couples Holding Hands Problem

LeetCode 765. There are n couples sitting in 2n seats...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

All Paths From Source To Target Problem

LeetCode 797. Given a directed acyclic graph (DAG) of n...

Number Of Provinces Problem

LeetCode 547. There are n cities. Some of them are...

Minimum Height Trees Problem

LeetCode 310. A tree is an undirected graph in which...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Course Schedule Problem

LeetCode 207. There are a total of numCourses courses you...

Course Schedule II Problem

LeetCode 210. There are a total of numCourses courses you...

Clone Graph Problem

LeetCode 133. Given a reference of a node in a...

Tag Design

Time Based Key-Value Store Problem

LeetCode 981. Design a time-based key-value data structure that can...

Rle Iterator Problem

LeetCode 900. We can use run-length encoding (i.e., RLE) to...

Online Stock Span Problem

LeetCode 901. Design an algorithm that collects daily price quotes...

Online Election Problem

LeetCode 911. You are given two integer arrays persons and...

Number Of Recent Calls Problem

LeetCode 933. You have a RecentCounter class which counts the...

Maximum Frequency Stack Problem

LeetCode 895. Design a stack-like data structure to push elements...

Exam Room Problem

LeetCode 855. There is an exam room with n seats...

Complete Binary Tree Inserter Problem

LeetCode 919. A complete binary tree is a binary tree...

Range Module Problem

LeetCode 715. A Range Module is a module that tracks...

My Calendar III Problem

LeetCode 732. A k-booking happens when k events have some...

My Calendar II Problem

LeetCode 731. You are implementing a program to use as...

My Calendar I Problem

LeetCode 729. You are implementing a program to use as...

Prefix And Suffix Search Problem

LeetCode 745. Design a special dictionary with some words that...

Design Circular Queue Problem

LeetCode 622. Design your implementation of the circular queue. The...

Design Circular Deque Problem

LeetCode 641. Design your implementation of the circular double-ended queue...

Map Sum Pairs Problem

LeetCode 677. Design a map that allows you to do...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

Implement Magic Dictionary Problem

LeetCode 676. Design a data structure that is initialized with...

Design Linked List Problem

LeetCode 707. Design your implementation of the linked list. You...

Design Hashset Problem

LeetCode 705. Design a HashSet without using any built-in hash...

Design Hashmap Problem

LeetCode 706. Design a HashMap without using any built-in hash...

Serialize And Deserialize BST Problem

LeetCode 449. Serialization is converting a data structure or object...

LFU Cache Problem

LeetCode 460. Design and implement a data structure for a...

Encode And Decode TinyURL Problem

LeetCode 535. TinyURL is a URL shortening service where you...

All O'One Data Structure Problem

LeetCode 432. Design a data structure to store the strings...

Serialize And Deserialize Binary Tree Problem

LeetCode 297. Serialization is the process of converting a data...

Range Sum Query - Immutable Problem

LeetCode 303. Given an integer array nums, handle multiple queries...

Range Sum Query 2D - Immutable Problem

LeetCode 304. Given a 2D matrix matrix, handle multiple queries...

Peeking Iterator Problem

LeetCode 284. Design an iterator that supports the peek operation...

Insert Delete Getrandom O(1) - Duplicates Allowed Problem

LeetCode 381. RandomizedCollection is a data structure that contains a...

Implement Stack Using Queues Problem

LeetCode 225. Implement a last-in-first-out (LIFO) stack using only two...

Implement Queue Using Stacks Problem

LeetCode 232. Implement a first in first out (FIFO) queue...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

Find Median From Data Stream Problem

LeetCode 295. The median is the middle value in an...

Design Twitter Problem

LeetCode 355. Design a simplified version of Twitter where users...

Design Add And Search Words Data Structure Problem

LeetCode 211. Design a data structure that supports adding new...

Data Stream As Disjoint Intervals Problem

LeetCode 352. Given a data stream input of non-negative integers...

Min Stack Problem

LeetCode 155. Design a stack that supports push, pop, top,...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Lru Cache Problem

LeetCode 146. Design a data structure that follows the constraints...

Tag Doubly-Linked List

LFU Cache Problem

LeetCode 460. Design and implement a data structure for a...

All O'One Data Structure Problem

LeetCode 432. Design a data structure to store the strings...

Lru Cache Problem

LeetCode 146. Design a data structure that follows the constraints...

Tag Geometry

Surface Area Of 3D Shapes Problem

LeetCode 892. You are given an n x n grid...

Rectangle Overlap Problem

LeetCode 836. An axis-aligned rectangle is represented as a list...

Projection Area Of 3D Shapes Problem

LeetCode 883. You are given an n x n grid...

Mirror Reflection Problem

LeetCode 858. There is a special square room with mirrors...

Minimum Area Rectangle Problem

LeetCode 939. You are given an array of points in...

Minimum Area Rectangle II Problem

LeetCode 963. You are given an array of points in...

Largest Triangle Area Problem

LeetCode 812. Given an array of points on the X-Y...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Erect The Fence Problem

LeetCode 587. You are given an array trees where trees[i]...

Valid Square Problem

LeetCode 593. Given the coordinates of four points in 2D...

Generate Random Point In A Circle Problem

LeetCode 478. Given the radius and the position of the...

Self Crossing Problem

LeetCode 335. You are given an array of integers distance....

Rectangle Area Problem

LeetCode 223. Given the coordinates of two rectilinear rectangles in...

Max Points On A Line Problem

LeetCode 149. Given an array of points where points[i] =...


Tag Merge Sort

Sort An Array Problem

LeetCode 912. Given an array of integers nums, sort the...

Reverse Pairs Problem

LeetCode 493. Given an integer array nums, return the number...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Sort List Problem

LeetCode 148. Given the head of a linked list, return...

Tag Memoization

All Possible Full Binary Trees Problem

LeetCode 894. Given an integer n, return a list of...

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Zuma Game Problem

LeetCode 488. You are playing a variation of the game...

Remove Boxes Problem

LeetCode 546. You are given several boxes with different colors...

Fibonacci Number Problem

LeetCode 509. The Fibonacci numbers, commonly denoted F(n) form a...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Integer Replacement Problem

LeetCode 397. Given a positive integer n,you can apply one...

Different Ways To Add Parentheses Problem

LeetCode 241. Given a string expression of numbers and operators,...

Word Break Problem

LeetCode 139. Given a string s and a dictionary of...

Word Break II Problem

LeetCode 140. Given a string s and a dictionary of...

Tag Iterator

Rle Iterator Problem

LeetCode 900. We can use run-length encoding (i.e., RLE) to...

Peeking Iterator Problem

LeetCode 284. Design an iterator that supports the peek operation...

Flatten Nested List Iterator Problem

LeetCode 341. You are given a nested list of integers...

Binary Search Tree Iterator Problem

LeetCode 173. Implement the BSTIterator class that represents an iterator...

Tag Counting

Subdomain Visit Count Problem

LeetCode 811. A website domain “discuss.leetcode.com” consists of various subdomains....

Subarrays With K Different Integers Problem

LeetCode 992. Given an integer array nums and an integer...

Rle Iterator Problem

LeetCode 900. We can use run-length encoding (i.e., RLE) to...

Reordered Power Of 2 Problem

LeetCode 869. You are given an integer n. We reorder...

Most Common Word Problem

LeetCode 819. Given a string paragraph and a string array...

Minimum Increment To Make Array Unique Problem

LeetCode 945. You are given an integer array nums. In...

Ransom Note Problem

LeetCode 383. Given two stings ransomNote and magazine, return true...

Majority Element II Problem

LeetCode 229. Given an integer array of size n, find...

First Unique Character In A String Problem

LeetCode 387. Given a string s, find the first non-repeating...

Bulls And Cows Problem

LeetCode 299. You are playing the Bulls and Cows game...

Majority Element Problem

LeetCode 169. Given an array nums of size n, return...


Tag Bucket Sort

Contains Duplicate III Problem

LeetCode 220. Given an integer array nums and two integers...

Maximum Gap Problem

LeetCode 164. Given an integer array nums, return the maximum...

Tag Radix Sort

Maximum Gap Problem

LeetCode 164. Given an integer array nums, return the maximum...

Tag Rolling Hash

Shortest Palindrome Problem

LeetCode 214. You are given a string s. You can...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...

Tag Hash Function

Design Hashset Problem

LeetCode 705. Design a HashSet without using any built-in hash...

Design Hashmap Problem

LeetCode 706. Design a HashMap without using any built-in hash...

Encode And Decode TinyURL Problem

LeetCode 535. TinyURL is a URL shortening service where you...

Shortest Palindrome Problem

LeetCode 214. You are given a string s. You can...

Repeated DNA Sequences Problem

LeetCode 187. The DNA sequence is composed of a series...


Tag Brainteaser

Nim Game Problem

LeetCode 292. You are playing the following Nim Game with...

Bulb Switcher Problem

LeetCode 319. There are n bulbs that are initially off....

Tag Ordered Set

Range Module Problem

LeetCode 715. A Range Module is a module that tracks...

Falling Squares Problem

LeetCode 699. There are several squares being dropped onto the...

Random Point In Non-Overlapping Rectangles Problem

LeetCode 497. You are given an array of non-overlapping axis-aligned...

132 Pattern Problem

LeetCode 456. Given an arrayof n integers nums, a 132...

Data Stream As Disjoint Intervals Problem

LeetCode 352. Given a data stream input of non-negative integers...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Contains Duplicate III Problem

LeetCode 220. Given an integer array nums and two integers...

Tag Binary Indexed Tree

Number Of Longest Increasing Subsequence Problem

LeetCode 673. Given an integer arraynums, return the number of...

Queue Reconstruction By Height Problem

LeetCode 406. You are given an array of people, people,...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...

Tag Segment Tree

Rectangle Area II Problem

LeetCode 850. You are given a 2D array of axis-aligned...

Range Module Problem

LeetCode 715. A Range Module is a module that tracks...

My Calendar III Problem

LeetCode 732. A k-booking happens when k events have some...

My Calendar II Problem

LeetCode 731. You are implementing a program to use as...

My Calendar I Problem

LeetCode 729. You are implementing a program to use as...

Number Of Longest Increasing Subsequence Problem

LeetCode 673. Given an integer arraynums, return the number of...

Falling Squares Problem

LeetCode 699. There are several squares being dropped onto the...

Queue Reconstruction By Height Problem

LeetCode 406. You are given an array of people, people,...

Count Of Smaller Numbers After Self Problem

LeetCode 315. You are given an integer array nums and...

Count Of Range Sum Problem

LeetCode 327. Given an integer array nums and two integers...


Tag Enumeration

Consecutive Numbers Sum Problem

LeetCode 829. Given an integer n, return the number of...

Count Primes Problem

LeetCode 204. Given an integer n, return the number of...

Tag Number Theory

Count Primes Problem

LeetCode 204. Given an integer n, return the number of...

Tag Topological Sort

Loud And Rich Problem

LeetCode 851. There is a group of n people labeled...

Cat And Mouse Problem

LeetCode 913. A game on an undirected graph is played...

Minimum Height Trees Problem

LeetCode 310. A tree is an undirected graph in which...

Longest Increasing Path In A Matrix Problem

LeetCode 329. Given an m x n integers matrix, return...

Course Schedule Problem

LeetCode 207. There are a total of numCourses courses you...

Course Schedule II Problem

LeetCode 210. There are a total of numCourses courses you...

Tag Monotonic Stack

Online Stock Span Problem

LeetCode 901. Design an algorithm that collects daily price quotes...

Odd Even Jump Problem

LeetCode 975. You are given an integer array arr. From...

Maximum Width Ramp Problem

LeetCode 962. A ramp in an integer array nums is...

Car Fleet Problem

LeetCode 853. There are n cars going to the same...

Max Chunks To Make Sorted Problem

LeetCode 769. You are given an integer array arr of...

Max Chunks To Make Sorted II Problem

LeetCode 768. You are given an integer array arr.

Maximum Binary Tree Problem

LeetCode 654. You are given an integer array nums with...

Daily Temperatures Problem

LeetCode 739. Given an array of integers temperatures represents the...

Shortest Unsorted Continuous Subarray Problem

LeetCode 581. Given an integer array nums, you need to...

Remove K Digits Problem

LeetCode 402. Given string num representing a non-negative integer num,...

Next Greater Element II Problem

LeetCode 503. Given a circular integer array nums (i.e., the...

Next Greater Element I Problem

LeetCode 496. The next greater element of some element x...

132 Pattern Problem

LeetCode 456. Given an arrayof n integers nums, a 132...

Remove Duplicate Letters Problem

LeetCode 316. Given a string s, remove duplicate letters so...

Create Maximum Number Problem

LeetCode 321. You are given two integer arrays nums1 and...


Tag Heap

Sort An Array Problem

LeetCode 912. Given an array of integers nums, sort the...

Shortest Subarray With Sum At Least K Problem

LeetCode 862. Given an integer array nums and an integer...

Reachable Nodes In Subdivided Graph Problem

LeetCode 882. You are given an undirected graph (the “original...

Minimum Number Of Refueling Stops Problem

LeetCode 871. A car travels from a starting position to...

Minimum Cost To Hire K Workers Problem

LeetCode 857. There are n workers. You are given two...

K Closest Points To Origin Problem

LeetCode 973. Given an array of points where points[i] =...

Top K Frequent Words Problem

LeetCode 692. Given an array of strings words and an...

Task Scheduler Problem

LeetCode 621. Given a characters array tasks, representing the tasks...

Swim In Rising Water Problem

LeetCode 778. You are given an n x n integer...

Reorganize String Problem

LeetCode 767. Given a string s, rearrange the characters of...

Network Delay Time Problem

LeetCode 743. You are given a network of n nodes,...

Split Array Into Consecutive Subsequences Problem

LeetCode 659. You are given an integer array nums that...

Smallest Range Covering Elements From K Lists Problem

LeetCode 632. You have k lists of sorted integers in...

Cut Off Trees For Golf Event Problem

LeetCode 675. You are asked to cut off all the...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

K-Th Smallest Prime Fraction Problem

LeetCode 786. You are given a sorted integer array arr...

Find K Closest Elements Problem

LeetCode 658. Given a sorted integer array arr, two integers...

Course Schedule III Problem

LeetCode 630. There are n different online courses numbered from...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

Trapping Rain Water II Problem

LeetCode 407. Given an m x n integer matrix heightMap...

Strong Password Checker Problem

LeetCode 420. A password is considered strong if the below...

IPO Problem

LeetCode 502. Suppose LeetCode will start its IPO soon. In...

Sort Characters By Frequency Problem

LeetCode 451. Given a string s, sort it in decreasing...

Sliding Window Median Problem

LeetCode 480. The median is the middle value in an...

Relative Ranks Problem

LeetCode 506. You are given an integer array score of...

Ugly Number II Problem

LeetCode 264. An ugly number is a positive integer whose...

Top K Frequent Elements Problem

LeetCode 347. Given an integer array nums and an integer...

Super Ugly Number Problem

LeetCode 313. A super ugly number is a positive integer...

Sliding Window Maximum Problem

LeetCode 239. You are given an array of integersnums, there...

Kth Largest Element In An Array Problem

LeetCode 215. Given an integer array nums and an integer...

Find Median From Data Stream Problem

LeetCode 295. The median is the middle value in an...

Find K Pairs With Smallest Sums Problem

LeetCode 373. You are given two integer arrays nums1 and...

Design Twitter Problem

LeetCode 355. Design a simplified version of Twitter where users...

Tag Shortest Path

Reachable Nodes In Subdivided Graph Problem

LeetCode 882. You are given an undirected graph (the “original...

Network Delay Time Problem

LeetCode 743. You are given a network of n nodes,...

Cheapest Flights Within K Stops Problem

LeetCode 787. There are n cities connected by some number...

Evaluate Division Problem

LeetCode 399. You are given an array of variable pairs...

Tag Data Stream

Online Stock Span Problem

LeetCode 901. Design an algorithm that collects daily price quotes...

Number Of Recent Calls Problem

LeetCode 933. You have a RecentCounter class which counts the...

Kth Largest Element In A Stream Problem

LeetCode 703. Design a class to find the k^th largest...

Find Median From Data Stream Problem

LeetCode 295. The median is the middle value in an...

Tag Interactive

Guess Number Higher Or Lower Problem

LeetCode 374. We are playing the Guess Game. The game...

First Bad Version Problem

LeetCode 278. You are a product manager and currently leading...


Tag Simulation

Walking Robot Simulation Problem

LeetCode 874. A robot on an infinite XY-plane starts at...

Backspace String Compare Problem

LeetCode 844. Given two strings s and t, return true...

Available Captures For Rook Problem

LeetCode 999. On an 8 x 8 chessboard, there is...

Solve The Equation Problem

LeetCode 640. Solve a given equation and return the value...

Baseball Game Problem

LeetCode 682. You are keeping score for a baseball game...

Teemo Attacking Problem

LeetCode 495. Our hero Teemo is attacking an enemy Ashe...

Reshape The Matrix Problem

LeetCode 566. In MATLAB, there is a handy function called...

Fraction Addition And Subtraction Problem

LeetCode 592. Given a string expression representing an expression of...

Diagonal Traverse Problem

LeetCode 498. Given an m x n matrix mat, return...

Complex Number Multiplication Problem

LeetCode 537. A complex number can be represented as a...

Fizz Buzz Problem

LeetCode 412. Given an integer n, return a string array...

Add Strings Problem

LeetCode 415. Given two non-negative integers, num1 and num2 represented...

Game Of Life Problem

LeetCode 289. The Game of Life, also known simply as...

Tag Game Theory

Nim Game Problem

LeetCode 292. You are playing the following Nim Game with...

Guess Number Higher Or Lower II Problem

LeetCode 375. We are playing the Guessing Game. The game...

Tag Counting Sort

Array Partition I Problem

LeetCode 561. Given an integer array nums of 2n integers,...

H-Index Problem

LeetCode 274. Given an array of integers citations where citations[i]...

Tag Randomized

Random Pick With Blacklist Problem

LeetCode 710. You are given an integer n and an...

Random Point In Non-Overlapping Rectangles Problem

LeetCode 497. You are given an array of non-overlapping axis-aligned...

Random Pick With Weight Problem

LeetCode 528. You are given a 0-indexed array of positive...

Random Flip Matrix Problem

LeetCode 519. There is an m x n binary grid...

Implement Rand10() Using Rand7() Problem

LeetCode 470. Given the API rand7() that generates a uniform...

Generate Random Point In A Circle Problem

LeetCode 478. Given the radius and the position of the...

Shuffle An Array Problem

LeetCode 384. Given an integer array nums, design an algorithm...

Random Pick Index Problem

LeetCode 398. Given an integer array nums with possible duplicates,...

Linked List Random Node Problem

LeetCode 382. Given a singly linked list, return a random...

Insert Delete Getrandom O(1) - Duplicates Allowed Problem

LeetCode 381. RandomizedCollection is a data structure that contains a...


Tag Quickselect

Kth Largest Element In An Array Problem

LeetCode 215. Given an integer array nums and an integer...

Tag Reservoir Sampling

Random Pick Index Problem

LeetCode 398. Given an integer array nums with possible duplicates,...

Linked List Random Node Problem

LeetCode 382. Given a singly linked list, return a random...

Tag Prefix Sum

Binary Subarrays With Sum Problem

LeetCode 930. Given a binary array nums and an integer...

Find Pivot Index Problem

LeetCode 724. Given an array of integers nums, calculate the...

Smallest Rotation With Highest Score Problem

LeetCode 798. You are given an array nums. You can...

Random Point In Non-Overlapping Rectangles Problem

LeetCode 497. You are given an array of non-overlapping axis-aligned...

Random Pick With Weight Problem

LeetCode 528. You are given a 0-indexed array of positive...

Contiguous Array Problem

LeetCode 525. Given a binary array nums, return the maximum...

Range Sum Query - Immutable Problem

LeetCode 303. Given an integer array nums, handle multiple queries...

Range Sum Query 2D - Immutable Problem

LeetCode 304. Given a 2D matrix matrix, handle multiple queries...

Product Of Array Except Self Problem

LeetCode 238. Given an integer array nums, return an array...

Minimum Size Subarray Sum Problem

LeetCode 209. Given an array of positive integers nums and...

Tag Line Sweep

Rectangle Area II Problem

LeetCode 850. You are given a 2D array of axis-aligned...

Perfect Rectangle Problem

LeetCode 391. Given an array rectangles where rectangles[i] = [x_i,...


Tag String Matching

Repeated Substring Pattern Problem

LeetCode 459. Given a string s, check if it can...

Shortest Palindrome Problem

LeetCode 214. You are given a string s. You can...

Tag Monotonic Queue

Sliding Window Maximum Problem

LeetCode 239. You are given an array of integersnums, there...

Tag Dyanmic Programming

Super Ugly Number Problem

LeetCode 313. A super ugly number is a positive integer...

Tag Rejection Sampling

Implement Rand10() Using Rand7() Problem

LeetCode 470. Given the API rand7() that generates a uniform...

Generate Random Point In A Circle Problem

LeetCode 478. Given the radius and the position of the...


Tag Probability and Statistics

Implement Rand10() Using Rand7() Problem

LeetCode 470. Given the API rand7() that generates a uniform...

Tag Bitmask

Split Array With Same Average Problem

LeetCode 805. You are given an integer array nums.

Shortest Path Visiting All Nodes Problem

LeetCode 847. You have an undirected, connected graph of n...

Find The Shortest Superstring Problem

LeetCode 943. Given an array of strings words, return the...

Stickers To Spell Word Problem

LeetCode 691. We are given n different types of stickers....

Shopping Offers Problem

LeetCode 638. In LeetCode Store, there are n items to...

Partition To K Equal Sum Subsets Problem

LeetCode 698. Given an integer array nums and an integer...

Matchsticks To Square Problem

LeetCode 473. You are given an integer array matchsticks where...