Hao Yi Cheah & LeetCode Solutions
Comprehensive LeetCode problem breakdowns, algorithmic intuition, time and space complexity analysis, and verified code solutions.
Algorithmic Mindset & Execution Principles
Solving LeetCode problems effectively isn't about memorizing code—it's about systematic pattern recognition. Approach every problem by analyzing constraints, selecting optimal data structures, and balancing time and space efficiency.
Pattern Recognition First
Map problem constraints to core algorithmic patterns (e.g., Two Pointers, Sliding Window, Monotonic Stack, DP) before writing any code.
Optimize Complexity Trade-offs
Evaluate time and space complexity upfront. Move from brute-force approaches to optimal bounds by choosing the right data structures.
Boundary & Edge Case Defense
Dry-run solutions against critical edge cases—empty inputs, single elements, duplicates, negative values, and integer bounds—prior to submission.
Algorithmic Patterns & Solutions
Comprehensive solution walkthroughs, optimal time/space complexity breakdowns, and interactive code implementations organized by topic.
Easy Problems
Fundamental data structure and algorithmic problems covering arrays, strings, two pointers, hash tables, and math.
- #1Two Sum→
- #7Reverse Integer→
- #9Palindrome Number→
- #13Roman to Integer→
- #14Longest Common Prefix→
- #20Valid Parentheses→
- #21Merge Two Sorted Lists→
- #26Remove Duplicates from Sorted Array→
- #27Remove Element→
- #28Implement strStr()→
- #35Search Insert Position→
- #53Maximum Subarray→
- #58Length of Last Word→
- #66Plus One→
- #67Add Binary→
- #69Sqrt(x)→
- #70Climbing Stairs→
- #83Remove Duplicates from Sorted List→
- #88Merge Sorted Array→
- #100Same Tree→
- #101Symmetric Tree→
- #104Maximum Depth of Binary Tree→
- #108Convert Sorted Array to Binary Search Tree→
- #110Balanced Binary Tree→
- #111Minimum Depth of Binary Tree→
- #112Path Sum→
- #118Pascal's Triangle→
- #119Pascal's Triangle II→
- #121Best Time to Buy and Sell Stock→
- #122Best Time to Buy and Sell Stock II→
- #125Valid Palindrome→
- #136Single Number→
- #141Linked List Cycle→
- #155Min Stack→
- #157Read N Characters Given Read4→
- #160Intersection of Two Linked Lists→
- #163Missing Ranges→
- #167Two Sum II - Input array is sorted→
- #168Excel Sheet Column Title→
- #169Majority Element→
- #170Two Sum III - Data structure design→
- #171Excel Sheet Column Number→
- #172Factorial Trailing Zeroes→
- #176Second Highest Salary→
- #182Duplicate Emails→
- #183Customers Who Never Order→
- #190Reverse Bits→
- #191Number of 1 Bits→
- #195Tenth Line→
- #196Delete Duplicate Emails→
- #197Rising Temperature→
- #202Happy Number→
- #203Remove Linked List Elements→
- #204Count Primes→
- #205Isomorphic Strings→
- #206Reverse Linked List→
- #217Contains Duplicate→
- #219Contains Duplicate II→
- #225Implement Stack using Queues→
- #226Invert Binary Tree→
- #228Summary Ranges→
- #231Power of Two→
- #232Implement Queue using Stacks→
- #234Palindrome Linked List→
- #235Lowest Common Ancestor of a Binary Search Tree→
- #237Delete Node in a Linked List→
- #242Valid Anagram→
- #243Shortest Word Distance→
- #246Strobogrammatic Number→
- #252Meeting Rooms→
- #257Binary Tree Paths→
- #258Add Digits→
- #263Ugly Number→
- #266Palindrome Permutation→
- #268Missing Number→
- #270Closest Binary Search Tree Value→
- #278First Bad Version→
- #283Move Zeroes→
- #290Word Pattern→
- #292Nim Game→
- #293Flip Game→
- #303Range Sum Query - Immutable→
- #326Power of Three→
- #342Power of Four→
- #344Reverse String→
- #345Reverse Vowels of a String→
- #346Moving Average from Data Stream→
- #349Intersection of Two Arrays→
- #350Intersection of Two Arrays II→
- #359Logger Rate Limiter→
- #367Valid Perfect Square→
- #374Guess Number Higher or Lower→
- #383Ransom Note→
- #387First Unique Character in a String→
- #389Find the Difference→
- #392Is Subsequence→
- #401Binary Watch→
- #404Sum of Left Leaves→
- #405Convert a Number to Hexadecimal→
- #408Valid Word Abbreviation→
- #409Longest Palindrome→
- #412Fizz Buzz→
- #414Third Maximum Number→
- #415Add Strings→
- #422Valid Word Square→
- #434Number of Segments in a String→
- #441Arranging Coins→
- #448Find All Numbers Disappeared in an Array→
- #453Minimum Moves to Equal Array Elements→
- #455Assign Cookies→
- #459Repeated Substring Pattern→
- #461Hamming Distance→
- #463Island Perimeter→
- #476Number Complement→
- #482License Key Formatting→
- #485Max Consecutive Ones→
- #492Construct the Rectangle→
- #496Next Greater Element I→
- #500Keyboard Row→
- #501Find Mode in Binary Search Tree→
- #504Base 7→
- #506Relative Ranks→
- #507Perfect Number→
- #509Fibonacci Number→
- #511Game Play Analysis I→
- #512Game Play Analysis II→
- #520Detect Capital→
- #521Longest Uncommon Subsequence I→
- #530Minimum Absolute Difference in BST→
- #541Reverse String II→
- #543Diameter of Binary Tree→
- #551Student Attendance Record I→
- #557Reverse Words in a String III→
- #559Maximum Depth of N-ary Tree→
- #561Array Partition I→
- #563Binary Tree Tilt→
- #566Reshape the Matrix→
- #572Subtree of Another Tree→
- #575Distribute Candies→
- #577Employee Bonus→
- #586Customer Placing the Largest Number of Orders→
- #589N-ary Tree Preorder Traversal→
- #590N-ary Tree Postorder Traversal→
- #594Longest Harmonious Subsequence→
- #595Big Countries→
- #596Classes More Than 5 Students→
- #597Friend Requests I: Overall Acceptance Rate→
- #598Range Addition II→
- #599Minimum Index Sum of Two Lists→
- #603Consecutive Available Seats→
- #604Design Compressed String Iterator→
- #605Can Place Flowers→
- #606Construct String from Binary Tree→
- #607Sales Person→
- #610Triangle Judgement→
- #613Shortest Distance in a Line→
- #617Merge Two Binary Trees→
- #619Biggest Single Number→
- #627Swap Salary→
- #628Maximum Product of Three Numbers→
- #637Average of Levels in Binary Tree→
- #643Maximum Average Subarray I→
- #645Set Mismatch→
- #653Two Sum IV - Input is a BST→
- #657Robot Return to Origin→
- #661Image Smoother→
- #671Second Minimum Node In a Binary Tree→
- #674Longest Continuous Increasing Subsequence→
- #680Valid Palindrome II→
- #682Baseball Game→
- #690Employee Importance→
- #693Binary Number with Alternating Bits→
- #696Count Binary Substrings→
- #697Degree of an Array→
- #700Search in a Binary Search Tree→
- #703Kth Largest Element in a Stream→
- #704Binary Search→
- #705Design HashSet→
- #706Design HashMap→
- #709To Lower Case→
- #716Max Stack→
- #7171-bit and 2-bit Characters→
- #720Longest Word in Dictionary→
- #724Find Pivot Index→
- #728Self Dividing Numbers→
- #733Flood Fill→
- #734Sentence Similarity→
- #744Find Smallest Letter Greater Than Target→
- #746Min Cost Climbing Stairs→
- #747Largest Number At Least Twice of Others→
- #748Shortest Completing Word→
- #758Bold Words in String→
- #760Find Anagram Mappings→
- #762Prime Number of Set Bits in Binary Representation→
- #766Toeplitz Matrix→
- #771Jewels and Stones→
- #783Minimum Distance Between BST Nodes→
- #788Rotated Digits→
- #796Rotate String→
- #800Similar RGB Color→
- #804Unique Morse Code Words→
- #806Number of Lines To Write String→
- #811Subdomain Visit Count→
- #812Largest Triangle Area→
- #819Most Common Word→
- #821Shortest Distance to a Character→
- #824Goat Latin→
- #830Positions of Large Groups→
- #832Flipping an Image→
- #836Rectangle Overlap→
- #844Backspace String Compare→
- #852Peak Index in a Mountain Array→
- #859Buddy Strings→
- #860Lemonade Change→
- #867Transpose Matrix→
- #868Binary Gap→
- #872Leaf-Similar Trees→
- #874Walking Robot Simulation→
- #876Middle of the Linked List→
- #883Projection Area of 3D Shapes→
- #884Uncommon Words from Two Sentences→
- #888Fair Candy Swap→
- #892Surface Area of 3D Shapes→
- #893Groups of Special-Equivalent Strings→
- #896Monotonic Array→
- #897Increasing Order Search Tree→
- #905Sort Array By Parity→
- #908Smallest Range I→
- #914X of a Kind in a Deck of Cards→
- #917Reverse Only Letters→
- #922Sort Array By Parity II→
- #925Long Pressed Name→
- #929Unique Email Addresses→
- #933Number of Recent Calls→
- #937Reorder Data in Log Files→
- #938Range Sum of BST→
- #941Valid Mountain Array→
- #942DI String Match→
- #944Delete Columns to Make Sorted→
- #953Verifying an Alien Dictionary→
- #961N-Repeated Element in Size 2N Array→
- #965Univalued Binary Tree→
- #976Largest Perimeter Triangle→
- #977Squares of a Sorted Array→
- #985Sum of Even Numbers After Queries→
- #989Add to Array-Form of Integer→
- #993Cousins in Binary Tree→
- #997Find the Town Judge→
- #999Available Captures for Rook→
- #1002Find Common Characters→
- #1005Maximize Sum Of Array After K Negations→
- #1009Complement of Base 10 Integer→
- #1013Partition Array Into Three Parts With Equal Sum→
- #1018Binary Prefix Divisible By 5→
- #1021Remove Outermost Parentheses→
- #1022Sum of Root To Leaf Binary Numbers→
- #1025Divisor Game→
- #1030Matrix Cells in Distance Order→
- #1033Moving Stones Until Consecutive→
- #1037Valid Boomerang→
- #1046Last Stone Weight→
- #1047Remove All Adjacent Duplicates In String→
- #1051Height Checker→
- #1056Confusing Number→
- #1064Fixed Point→
- #1065Index Pairs of a String→
- #1069Product Sales Analysis II→
- #1071Greatest Common Divisor of Strings→
- #1075Project Employees I→
- #1076Project Employees II→
- #1078Occurrences After Bigram→
- #1082Sales Analysis I→
- #1083Sales Analysis II→
- #1084Sales Analysis III→
- #1085Sum of Digits in the Minimum Number→
- #1086High Five→
- #1089Duplicate Zeros→
- #1099Two Sum Less Than K→
- #1103Distribute Candies to People→
- #1108Defanging an IP Address→
- #1114Print in Order→
- #1118Number of Days in a Month→
- #1119Remove Vowels from a String→
- #1122Relative Sort Array→
- #1128Number of Equivalent Domino Pairs→
- #1133Largest Unique Number→
- #1134Armstrong Number→
- #1137N-th Tribonacci Number→
- #1141User Activity for the Past 30 Days I→
- #1142User Activity for the Past 30 Days II→
- #1150Check If a Number Is Majority Element in a Sorted Array→
- #1154Day of the Year→
- #1160Find Words That Can Be Formed by Characters→
- #1165Single-Row Keyboard→
- #1173Immediate Food Delivery I→
- #1175Prime Arrangements→
- #1176Diet Plan Performance→
- #1180Count Substrings with Only One Distinct Letter→
- #1184Distance Between Bus Stops→
- #1185Day of the Week→
- #1189Maximum Number of Balloons→
- #1196How Many Apples Can You Put into the Basket→
- #1200Minimum Absolute Difference→
- #1207Unique Number of Occurrences→
- #1211Queries Quality and Percentage→
- #1213Intersection of Three Sorted Arrays→
- #1217Minimum Cost to Move Chips to The Same Position→
- #1221Split a String in Balanced Strings→
- #1228Missing Number In Arithmetic Progression→
- #1232Check If It Is a Straight Line→
- #1241Number of Comments per Post→
- #1243Array Transformation→
- #1251Average Selling Price→
- #1252Cells with Odd Values in a Matrix→
- #1260Shift 2D Grid→
- #1266Minimum Time Visiting All Points→
- #1271Hexspeak→
- #1275Find Winner on a Tic Tac Toe Game→
- #1279Traffic Light Controlled Intersection→
- #1280Students and Examinations→
- #1281Subtract the Product and Sum of Digits of an Integer→
- #1287Element Appearing More Than 25% In Sorted Array→
- #1290Convert Binary Number in a Linked List to Integer→
- #1295Find Numbers with Even Number of Digits→
- #1299Replace Elements with Greatest Element on Right Side→
- #1303Find the Team Size→
- #1304Find N Unique Integers Sum up to Zero→
- #1309Decrypt String from Alphabet to Integer Mapping→
- #1313Decompress Run-Length Encoded List→
- #1317Convert Integer to the Sum of Two No-Zero Integers→
- #1322Ads Performance→
- #1323Maximum 69 Number→
- #1327List the Products Ordered in a Period→
- #1331Rank Transform of an Array→
- #1332Remove Palindromic Subsequences→
- #1337The K Weakest Rows in a Matrix→
- #1342Number of Steps to Reduce a Number to Zero→
- #1346Check If N and Its Double Exist→
- #1350Students With Invalid Departments→
- #1351Count Negative Numbers in a Sorted Matrix→
- #1356Sort Integers by The Number of 1 Bits→
- #1360Number of Days Between Two Dates→
- #1365How Many Numbers Are Smaller Than the Current Number→
- #1370Increasing Decreasing String→
- #1374Generate a String With Characters That Have Odd Counts→
- #1378Replace Employee ID With The Unique Identifier→
- #1380Lucky Numbers in a Matrix→
- #1385Find the Distance Value Between Two Arrays→
- #1389Create Target Array in the Given Order→
- #1394Find Lucky Integer in an Array→
- #1399Count Largest Group→
- #1403Minimum Subsequence in Non-Increasing Order→
- #1407Top Travellers→
- #1408String Matching in an Array→
- #1413Minimum Value to Get Positive Step by Step Sum→
- #1417Reformat The String→
- #1422Maximum Score After Splitting a String→
- #1426Counting Elements→
- #1427Perform String Shifts→
- #1431Kids With the Greatest Number of Candies→
- #1435Create a Session Bar Chart→
- #1436Destination City→
- #1437Check If All 1's Are at Least Length K Places Away→
- #1441Build an Array With Stack Operations→
- #1446Consecutive Characters→
- #1450Number of Students Doing Homework at a Given Time→
- #1455Check If a Word Occurs As a Prefix of Any Word in a Sentence→
- #1460Make Two Arrays Equal by Reversing Sub-arrays→
- #1464Maximum Product of Two Elements in an Array→
- #1469Find All The Lonely Nodes→
- #1470Shuffle the Array→
- #1474Delete N Nodes After M Nodes of a Linked List→
- #1475Final Prices With a Special Discount in a Shop→
- #1480Running Sum of 1d Array→
- #1484Group Sold Products By The Date→
- #1486XOR Operation in an Array→
- #1491Average Salary Excluding the Minimum and Maximum Salary→
- #1495Friendly Movies Streamed Last Month→
- #1496Path Crossing→
- #1502Can Make Arithmetic Progression From Sequence→
- #1507Reformat Date→
- #1511Customer Order Frequency→
- #1512Number of Good Pairs→
- #1518Water Bottles→
- #1523Count Odd Numbers in an Interval Range→
- #1527Patients With a Condition→
- #1528Shuffle String→
- #1534Count Good Triplets→
- #1539Kth Missing Positive Number→
- #1543Fix Product Name Format→
- #1544Make The String Great→
- #1550Three Consecutive Odds→
- #1556Thousand Separator→
- #1560Most Visited Sector in a Circular Track→
- #1565Unique Orders and Customers Per Month→
- #1566Detect Pattern of Length M Repeated K or More Times→
- #1571Warehouse Manager→
- #1572Matrix Diagonal Sum→
- #1576Replace All ?'s to Avoid Consecutive Repeating Characters→
- #1582Special Positions in a Binary Matrix→
- #1587Bank Account Summary II→
- #1588Sum of All Odd Length Subarrays→
- #1592Rearrange Spaces Between Words→
- #1598Crawler Log Folder→
- #1603Design Parking System→
- #1607Sellers With No Sales→
- #1608Special Array With X Elements Greater Than or Equal X→
- #1614Maximum Nesting Depth of the Parentheses→
- #1619Mean of Array After Removing Some Elements→
- #1624Largest Substring Between Two Equal Characters→
- #1629Slowest Key→
- #1633Percentage of Users Attended a Contest→
- #1636Sort Array by Increasing Frequency→
- #1640Check Array Formation Through Concatenation→
- #1646Get Maximum in Generated Array→
- #1652Defuse the Bomb→
- #1656Design an Ordered Stream→
- #1661Average Time of Process per Machine→
- #1662Check If Two String Arrays are Equivalent→
- #1667Fix Names in a Table→
- #1668Maximum Repeating Substring→
- #1672Richest Customer Wealth→
- #1677Product's Worth Over Invoices→
- #1678Goal Parser Interpretation→
- #1684Count the Number of Consistent Strings→
- #1688Count of Matches in Tournament→
- #1693Daily Leads and Partners→
- #1694Reformat Phone Number→
- #1700Number of Students Unable to Eat Lunch→
- #1704Determine if String Halves Are Alike→
- #1708Largest Subarray Length K→
- #1710Maximum Units on a Truck→
- #1716Calculate Money in Leetcode Bank→
- #1720Decode XORed Array→
- #1725Number Of Rectangles That Can Form The Largest Square→
- #1731The Number of Employees Which Report to Each Employee→
- #1732Find the Highest Altitude→
- #1736Latest Time by Replacing Hidden Digits→
- #1741Find Total Time Spent by Each Employee→
- #1742Maximum Number of Balls in a Box→
- #1748Sum of Unique Elements→
- #1752Check if Array Is Sorted and Rotated→
- #1758Minimum Changes To Make Alternating Binary String→
- #1763Longest Nice Substring→
- #1768Merge Strings Alternately→
- #1773Count Items Matching a Rule→
- #1777Product's Price for Each Store→
- #1779Find Nearest Point That Has the Same X or Y Coordinate→
- #1784Check if Binary String Has at Most One Segment of Ones→
- #1789Primary Department for Each Employee→
- #1790Check if One String Swap Can Make Strings Equal→
- #1795Rearrange Products Table→
- #1796Second Largest Digit in a String→
- #1800Maximum Ascending Subarray Sum→
- #1805Number of Different Integers in a String→
- #1809Ad-Free Sessions→
- #1812Determine Color of a Chessboard Square→
- #1816Truncate Sentence→
- #1822Sign of the Product of an Array→
Medium Problems
Intermediate algorithmic challenges involving dynamic programming, trees, graphs, backtracking, and optimization.
- #2Add Two Numbers→
- #3Longest Substring Without Repeating Characters→
- #5Longest Palindromic Substring→
- #6ZigZag Conversion→
- #8String to Integer (atoi)→
- #11Container With Most Water→
- #12Integer to Roman→
- #153Sum→
- #163Sum Closest→
- #17Letter Combinations of a Phone Number→
- #184Sum→
- #22Generate Parentheses→
- #24Swap Nodes in Pairs→
- #29Divide Two Integers→
- #31Next Permutation→
- #34Find First and Last Position of Element in Sorted Array→
- #36Valid Sudoku→
- #38Count and Say→
- #39Combination Sum→
- #40Combination Sum II→
- #45Jump Game II→
- #46Permutations→
- #47Permutations II→
- #48Rotate Image→
- #49Group Anagrams→
- #50Pow(x, n)→
- #54Spiral Matrix→
- #55Jump Game→
- #56Merge Intervals→
- #59Spiral Matrix II→
- #62Unique Paths→
- #63Unique Paths II→
- #64Minimum Path Sum→
- #71Simplify Path→
- #74Search a 2D Matrix→
- #75Sort Colors→
- #77Combinations→
- #78Subsets→
- #79Word Search→
- #81Search in Rotated Sorted Array II→
- #86Partition List→
- #89Gray Code→
- #90Subsets II→
- #91Decode Ways→
- #93Restore IP Addresses→
- #94Binary Tree Inorder Traversal→
- #95Unique Binary Search Trees II→
- #96Unique Binary Search Trees→
- #97Interleaving String→
- #98Validate Binary Search Tree→
- #102Binary Tree Level Order Traversal→
- #103Binary Tree Zigzag Level Order Traversal→
- #105Construct Binary Tree from Preorder and Inorder Traversal→
- #107Binary Tree Level Order Traversal II→
- #113Path Sum II→
- #116Populating Next Right Pointers in Each Node→
- #120Triangle→
- #129Sum Root to Leaf Numbers→
- #130Surrounded Regions→
- #131Palindrome Partitioning→
- #133Clone Graph→
- #134Gas Station→
- #137Single Number II→
- #138Copy List with Random Pointer→
- #139Word Break→
- #142Linked List Cycle II→
- #143Reorder List→
- #144Binary Tree Preorder Traversal→
- #146LRU Cache→
- #148Sort List→
- #150Evaluate Reverse Polish Notation→
- #151Reverse Words in a String→
- #152Maximum Product Subarray→
- #153Find Minimum in Rotated Sorted Array→
- #159Longest Substring with At Most Two Distinct Characters→
- #161One Edit Distance→
- #162Find Peak Element→
- #165Compare Version Numbers→
- #166Fraction to Recurring Decimal→
- #173Binary Search Tree Iterator→
- #177Nth Highest Salary→
- #178Rank Scores→
- #179Largest Number→
- #180Consecutive Numbers→
- #184Department Highest Salary→
- #186Reverse Words in a String II→
- #187Repeated DNA Sequences→
- #192Word Frequency→
- #194Transpose File→
- #198House Robber→
- #199Binary Tree Right Side View→
- #200Number of Islands→
- #201Bitwise AND of Numbers Range→
- #207Course Schedule→
- #208Implement Trie (Prefix Tree)→
- #209Minimum Size Subarray Sum→
- #210Course Schedule II→
- #211Design Add and Search Words Data Structure→
- #213House Robber II→
- #215Kth Largest Element in an Array→
- #216Combination Sum III→
- #221Maximal Square→
- #223Rectangle Area→
- #229Majority Element II→
- #230Kth Smallest Element in a BST→
- #236Lowest Common Ancestor of a Binary Tree→
- #238Product of Array Except Self→
- #240Search a 2D Matrix II→
- #241Different Ways to Add Parentheses→
- #244Shortest Word Distance II→
- #249Group Shifted Strings→
- #250Count Univalue Subtrees→
- #253Meeting Rooms II→
- #256Paint House→
- #260Single Number III→
- #261Graph Valid Tree→
- #264Ugly Number II→
- #267Palindrome Permutation II→
- #271Encode and Decode Strings→
- #275H-Index II→
- #277Find the Celebrity→
- #279Perfect Squares→
- #284Peeking Iterator→
- #286Walls and Gates→
- #287Find the Duplicate Number→
- #288Unique Word Abbreviation→
- #291Word Pattern II→
- #294Flip Game II→
- #298Binary Tree Longest Consecutive Sequence→
- #299Bulls and Cows→
- #300Longest Increasing Subsequence→
- #304Range Sum Query 2D - Immutable→
- #306Additive Number→
- #307Range Sum Query - Mutable→
- #310Minimum Height Trees→
- #311Sparse Matrix Multiplication→
- #313Super Ugly Number→
- #314Binary Tree Vertical Order Traversal→
- #316Remove Duplicate Letters→
- #318Maximum Product of Word Lengths→
- #319Bulb Switcher→
- #322Coin Change→
- #323Number of Connected Components in an Undirected Graph→
- #325Maximum Size Subarray Sum Equals k→
- #332Reconstruct Itinerary→
- #334Increasing Triplet Subsequence→
- #337House Robber III→
- #338Counting Bits→
- #339Nested List Weight Sum→
- #340Longest Substring with At Most K Distinct Characters→
- #343Integer Break→
- #347Top K Frequent Elements→
- #351Android Unlock Patterns→
- #365Water and Jug Problem→
- #366Find Leaves of Binary Tree→
- #368Largest Divisible Subset→
- #370Range Addition→
- #371Sum of Two Integers→
- #372Super Pow→
- #373Find K Pairs with Smallest Sums→
- #376Wiggle Subsequence→
- #377Combination Sum IV→
- #378Kth Smallest Element in a Sorted Matrix→
- #379Design Phone Directory→
- #380Insert Delete GetRandom O(1)→
- #384Shuffle an Array→
- #395Longest Substring with At Least K Repeating Characters→
- #397Integer Replacement→
- #398Random Pick Index→
- #399Evaluate Division→
- #400Nth Digit→
- #402Remove K Digits→
- #406Queue Reconstruction by Height→
- #413Arithmetic Slices→
- #416Partition Equal Subset Sum→
- #417Pacific Atlantic Water Flow→
- #419Battleships in a Board→
- #421Maximum XOR of Two Numbers in an Array→
- #424Longest Repeating Character Replacement→
- #427Construct Quad Tree→
- #429N-ary Tree Level Order Traversal→
- #433Minimum Genetic Mutation→
- #435Non-overlapping Intervals→
- #436Find Right Interval→
- #438Find All Anagrams in a String→
- #442Find All Duplicates in an Array→
- #443String Compression→
- #444Sequence Reconstruction→
- #445Add Two Numbers II→
- #447Number of Boomerangs→
- #449Serialize and Deserialize BST→
- #450Delete Node in a BST→
- #451Sort Characters By Frequency→
- #452Minimum Number of Arrows to Burst Balloons→
- #4544Sum II→
- #462Minimum Moves to Equal Array Elements II→
- #464Can I Win→
- #468Validate IP Address→
- #469Convex Polygon→
- #470Implement Rand10() Using Rand7()→
- #473Matchsticks to Square→
- #474Ones and Zeroes→
- #475Heaters→
- #477Total Hamming Distance→
- #478Generate Random Point in a Circle→
- #481Magical String→
- #486Predict the Winner→
- #487Max Consecutive Ones II→
- #490The Maze→
- #491Increasing Subsequences→
- #494Target Sum→
- #495Teemo Attacking→
- #505The Maze II→
- #508Most Frequent Subtree Sum→
- #515Find Largest Value in Each Tree Row→
- #516Longest Palindromic Subsequence→
- #518Coin Change 2→
- #524Longest Word in Dictionary through Deleting→
- #525Contiguous Array→
- #526Beautiful Arrangement→
- #528Random Pick with Weight→
- #529Minesweeper→
- #531Lonely Pixel I→
- #532K-diff Pairs in an Array→
- #534Game Play Analysis III→
- #535Encode and Decode TinyURL→
- #537Complex Number Multiplication→
- #539Minimum Time Difference→
- #54201 Matrix→
- #545Boundary of Binary Tree→
- #547Number of Provinces→
- #550Game Play Analysis IV→
- #553Optimal Division→
- #554Brick Wall→
- #556Next Greater Element III→
- #560Subarray Sum Equals K→
- #562Longest Line of Consecutive One in Matrix→
- #565Array Nesting→
- #567Permutation in String→
- #570Managers with at Least 5 Direct Reports→
- #574Winning Candidate→
- #576Out of Boundary Paths→
- #580Count Student Number in Departments→
- #581Shortest Unsorted Continuous Subarray→
- #582Kill Process→
- #583Delete Operation for Two Strings→
- #585Investments in 2016→
- #592Fraction Addition and Subtraction→
- #593Valid Square→
- #602Friend Requests II: Who Has the Most Friends→
- #608Tree Node→
- #609Find Duplicate File in System→
- #612Shortest Distance in a Plane→
- #614Second Degree Follower→
- #616Add Bold Tag in String→
- #621Task Scheduler→
- #622Design Circular Queue→
- #625Minimum Factorization→
- #626Exchange Seats→
- #633Sum of Square Numbers→
- #634Find the Derangement of An Array→
- #638Shopping Offers→
- #640Solve the Equation→
- #641Design Circular Deque→
- #646Maximum Length of Pair Chain→
- #647Palindromic Substrings→
- #648Replace Words→
- #669Trim a Binary Search Tree→
- #673Number of Longest Increasing Subsequence→
- #676Implement Magic Dictionary→
- #688Knight Probability in Chessboard→
- #695Max Area of Island→
- #701Insert into a Binary Search Tree→
- #712Minimum ASCII Delete Sum for Two Strings→
- #713Subarray Product Less Than K→
- #718Maximum Length of Repeated Subarray→
- #729My Calendar I→
- #737Sentence Similarity II→
- #739Daily Temperatures→
- #743Network Delay Time→
- #750Number Of Corner Rectangles→
- #752Open the Lock→
- #754Reach a Number→
- #756Pyramid Transition Matrix→
- #763Partition Labels→
- #767Reorganize String→
- #769Max Chunks To Make Sorted→
- #781Rabbits in Forest→
- #784Letter Case Permutation→
- #785Is Graph Bipartite?→
- #791Custom Sort String→
- #792Number of Matching Subsequences→
- #794Valid Tic-Tac-Toe State→
- #795Number of Subarrays with Bounded Maximum→
- #797All Paths From Source to Target→
- #799Champagne Tower→
- #807Max Increase to Keep City Skyline→
- #808Soup Servings→
- #809Expressive Words→
- #814Binary Tree Pruning→
- #817Linked List Components→
- #823Binary Trees With Factors→
- #826Most Profit Assigning Work→
- #840Magic Squares In Grid→
- #841Keys and Rooms→
- #842Split Array into Fibonacci Sequence→
- #846Hand of Straights→
- #848Shifting Letters→
- #851Loud and Rich→
- #861Score After Flipping Matrix→
- #863All Nodes Distance K in Binary Tree→
- #865Smallest Subtree with all the Deepest Nodes→
- #866Prime Palindrome→
- #869Reordered Power of 2→
- #875Koko Eating Bananas→
- #881Boats to Save People→
- #886Possible Bipartition→
- #890Find and Replace Pattern→
- #894All Possible Full Binary Trees→
- #898Bitwise ORs of Subarrays→
- #900RLE Iterator→
- #904Fruit Into Baskets→
- #912Sort an Array→
- #916Word Subsets→
- #918Maximum Sum Circular Subarray→
- #921Minimum Add to Make Parentheses Valid→
- #930Binary Subarrays With Sum→
- #931Minimum Falling Path Sum→
- #935Knight Dialer→
- #939Minimum Area Rectangle Review→
- #945Minimum Increment to Make Array Unique→
- #946Validate Stack Sequences→
- #947Most Stones Removed with Same Row or Column→
- #948Bag of Tokens→
- #949Largest Time from Digits→
- #950Reveal Cards In Increasing Order→
- #951Flip Equivalent Binary Trees→
- #955Delete Columns to Make Sorted II→
- #957Prison Cells After N Days→
- #958Check Completeness of a Binary Tree→
- #966Vowel Spellchecker→
- #967Numbers With Same Consecutive Differences→
- #970Powerful Integers→
- #973K Closest Points to Origin→
- #974Subarray Sums Divisible by K→
- #979Distribute Coins in Binary Tree→
- #981Time Based Key-Value Store→
- #984String Without AAA or BBB→
- #986Interval List Intersections→
- #988Smallest String Starting From Leaf→
- #990Satisfiability of Equality Equations→
- #991Broken Calculator→
- #994Rotting Oranges→
- #1003Check If Word Is Valid After Substitutions→
- #1004Max Consecutive Ones III→
- #1007Minimum Domino Rotations For Equal Row→
- #1008Construct Binary Search Tree from Preorder Traversal→
- #1010Pairs of Songs With Total Durations Divisible by 60→
- #1011Capacity To Ship Packages Within D Days→
- #1014Best Sightseeing Pair→
- #1015Smallest Integer Divisible by K→
- #1019Next Greater Node In Linked List→
- #1020Number of Enclaves→
- #1023Camelcase Matching→
- #1024Video Stitching→
- #1026Maximum Difference Between Node and Ancestor→
- #1035Uncrossed Lines→
- #1041Robot Bounded In Circle→
- #1042Flower Planting With No Adjacent→
- #1043Partition Array for Maximum Sum→
- #1045Customers Who Bought All Products→
- #1048Longest String Chain→
- #1049Last Stone Weight II→
- #1052Grumpy Bookstore Owner→
- #1057Campus Bikes→
- #1061Lexicographically Smallest Equivalent String→
- #1062Longest Repeating Substring→
- #1066Campus Bikes II→
- #1070Product Sales Analysis III→
- #1072Flip Columns For Maximum Number of Equal Rows→
- #1077Project Employees III→
- #1079Letter Tile Possibilities→
- #1081Smallest Subsequence of Distinct Characters→
- #1087Brace Expansion→
- #1090Largest Values From Labels→
- #1091Shortest Path in Binary Matrix→
- #1093Statistics from a Large Sample→
- #1094Car Pooling→
- #1096Remove Sub-Folders from the Filesystem→
- #1098Unpopular Books→
- #1100Find K-Length Substrings With No Repeated Characters→
- #1101The Earliest Moment When Everyone Become Friends→
- #1102Path With Maximum Minimum Value→
- #1105Filling Bookcase Shelves→
- #1107New Users Daily Count→
- #1109Corporate Flight Bookings→
- #1112Highest Grade For Each Student→
- #1115Print FooBar Alternately→
- #1120Maximum Average Subtree→
- #1126Active Businesses→
- #1130Minimum Cost Tree From Leaf Values→
- #1131Maximum of Absolute Value Expression→
- #1135Connecting Cities With Minimum Cost→
- #1136Parallel Courses→
- #1140Stone Game II→
- #1143Longest Common Subsequence→
- #1151Minimum Swaps to Group All 1's Together→
- #1152Analyze User Website Visit Pattern→
- #1155Number of Dice Rolls With Target Sum→
- #1158Market Analysis I→
- #1161Maximum Level Sum of a Binary Tree→
- #1162As Far from Land as Possible→
- #1164Product Price at a Given Date→
- #1167Minimum Cost to Connect Sticks→
- #1170Compare Strings by Frequency of the Smallest Character→
- #1181Before and After Puzzle→
- #1182Shortest Distance to Target Color→
- #1188Design Bounded Blocking Queue→
- #1193Monthly Transactions I→
- #1197Minimum Knight Moves→
- #1198Find Smallest Common Element in All Rows→
- #1201Ugly Number III→
- #1202Smallest String With Swaps→
- #1205Monthly Transactions II→
- #1208Get Equal Substrings Within Budget→
- #1209Remove All Adjacent Duplicates in String II→
- #1212Team Scores in Football Tournament→
- #1214Two Sum BSTs→
- #1215Stepping Numbers→
- #1219Path with Maximum Gold→
- #1222Queens That Can Attack the King→
- #1227Airplane Seat Assignment Probability→
- #1230Toss Strange Coins→
- #1234Replace the Substring for Balanced String→
- #1236Web Crawler→
- #1238Circular Permutation in Binary Representation→
- #1239Maximum Length of a Concatenated String with Unique Characters→
- #1244Design A Leaderboard→
- #1245Tree Diameter→
- #1249Minimum Remove to Make Valid Parentheses→
- #1253Reconstruct a 2-Row Binary Matrix→
- #1254Number of Closed Islands→
- #1257Smallest Common Region→
- #1258Synonymous Sentences→
- #1261Find Elements in a Contaminated Binary Tree→
- #1262Greatest Sum Divisible by Three→
- #1264Page Recommendations→
- #1265Print Immutable Linked List in Reverse→
- #1267Count Servers that Communicate→
- #1270All People Report to the Given Manager→
- #1272Remove Interval→
- #1276Number of Burgers with No Waste of Ingredients→
- #1277Count Square Submatrices with All Ones→
- #1282Group the People Given the Group Size They Belong To→
- #1283Find the Smallest Divisor Given a Threshold→
- #1285Find the Start and End Number of Continuous Ranges→
- #1286Iterator for Combination→
- #1288Remove Covered Intervals→
- #1291Sequential Digits→
- #1292Maximum Side Length of a Square with Sum Less than or Equal to Threshold→
- #1297Maximum Number of Occurrences of a Substring→
- #1302Deepest Leaves Sum→
- #1305All Elements in Two Binary Search Trees→
- #1306Jump Game III→
- #1310XOR Queries of a Subarray→
- #1314Matrix Block Sum→
- #1318Minimum Flips to Make a OR b Equal to c→
- #1319Number of Operations to Make Network Connected→
- #1324Print Words Vertically→
- #1325Delete Leaves With a Given Value→
- #1329Sort the Matrix Diagonally→
- #1333Filter Restaurants by Vegan-Friendly, Price and Distance→
- #1334Find the City With the Smallest Number of Neighbors at a Threshold Distance→
- #1338Reduce Array Size To The Half→
- #1339Maximum Product of Splitted Binary Tree→
- #1341Movie Rating→
- #1343Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold→
- #1344Angle Between Hands of a Clock→
- #1347Minimum Number of Steps to Make Two Strings Anagram→
- #1355Activity Participants→
- #1357Apply Discount Every n Orders→
- #1361Validate Binary Tree Nodes→
- #1362Closest Divisors→
- #1364Number of Trusted Contacts of a Customer→
- #1366Rank Teams by Votes→
- #1367Linked List in Binary Tree→
- #1371Find the Longest Substring Containing Vowels in Even Counts→
- #1375Bulb Switcher III→
- #1376Time Needed to Inform All Employees→
- #1379Find a Corresponding Node of a Binary Tree in a Clone of That Tree→
- #1382Balance a Binary Search Tree→
- #1387Sort Integers by The Power Value→
- #1390Four Divisors→
- #1391Check if There is a Valid Path in a Grid→
- #1393Capital Gain/Loss→
- #1395Count Number of Teams→
- #1396Design Underground System→
- #1398Customers Who Bought Products A and B but Not C→
- #1401Circle and Rectangle Overlapping→
- #1404Number of Steps to Reduce a Number in Binary Representation to One→
- #1405Longest Happy String→
- #1409Queries on a Permutation With Key→
- #1410HTML Entity Parser→
- #1414Find the Minimum Number of Fibonacci Numbers Whose Sum Is K→
- #1418Display Table of Food Orders in a Restaurant→
- #1421NPV Queries→
- #1423Maximum Points You Can Obtain from Cards→
- #1433Check If a String Can Break Another String→
- #1438Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit→
- #1440Evaluate Boolean Expression→
- #1445Apples & Oranges→
- #1447Simplified Fractions→
- #1448Count Good Nodes in Binary Tree - Review & Correction→
- #1451Rearrange Words in a Sentence→
- #1452People Whose List of Favorite Companies Is Not a Subset of Another List→
- #1456Maximum Number of Vowels in a Substring of Given Length→
- #1457Pseudo-Palindromic Paths in a Binary Tree→
- #1459Rectangles Area→
- #1461Check If a String Contains All Binary Codes of Size K→
- #1462Course Schedule IV→
- #1465Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts→
- #1468Calculate Salaries→
- #1472Design Browser History→
- #1476Subrectangle Queries→
- #1481Least Number of Unique Integers after K Removals→
- #1482Minimum Number of Days to Make m Bouquets→
- #1490Clone N-ary Tree→
- #1492The kth Factor of n→
- #1497Check If Array Pairs Are Divisible by k→
- #1501Countries You Can Safely Invest In→
- #1503Last Moment Before All Ants Fall Out of a Plank→
- #1508Range Sum of Sorted Subarray Sums→
- #1513Number of Substrings With Only 1s→
- #1514Path with Maximum Probability→
- #1519Number of Nodes in the Sub-Tree With the Same Label→
- #1524Number of Sub-arrays With Odd Sum→
- #1529Bulb Switcher IV→
- #1530Number of Good Leaf Nodes Pairs→
- #1532The Most Recent Three Orders→
- #1549The Most Recent Orders for Each Product→
- #1552Magnetic Force Between Two Balls→
- #1555Bank Account Summary→
- #1557Minimum Number of Vertices to Reach All Nodes→
- #1570Dot Product of Two Sparse Vectors→
- #1577Number of Ways Where Square of Number Is Equal to Product of Two Numbers→
- #1578Minimum Deletion Cost to Avoid Repeating Letters→
- #1584Min Cost to Connect All Points→
- #1589Maximum Sum Obtained of Any Permutation→
- #1593Split a String Into the Max Number of Unique Substrings→
- #1594Maximum Non Negative Product in a Matrix→
- #1596The Most Frequently Ordered Products for Each Customer→
Hard Problems
Advanced algorithms, complex data structures, graph flows, interval segment trees, and challenging edge-case optimizations.
Upcoming solutions will be published here in the next phase.