C++/Shell/SQL source code of solved LeetCode problems.
The list is sorted by problem number.
Expand Solution List
- 1. Two Sum
- 5. Longest Palindromic Substring
- 8. String to Integer (atoi)
- 9. Palindrome Number
- 11. Container With Most Water
- 13. Roman to Integer
- 14. Longest Common Prefix
- 17. Letter Combinations of a Phone Number
- 26. Remove Duplicates from Sorted Array
- 27. Remove Element
- 28. Find the Index of the First Occurrence in a String
- 36. Valid Sudoku
- 37. Sudoku Solver
- 41. First Missing Positive
- 42. Trapping Rain Water
- 51. N Queens
- 52. N Queens II
- 58. Length of Last Word
- 62. Unique Paths
- 63. Unique Paths II
- 64. Minimum Path Sum
- 66. Plus One
- 69. Sqrt(x)
- 70. Climbing Stairs
- 72. Edit Distance
- 76. Minimum Window Substring
- 84. Largest Rectangle in Histogram
- 85. Maximal Rectangle
- 88. Merge Sorted Array
- 91. Decode Ways
- 95. Unique Binary Search Trees II
- 96. Unique Binary Search Trees
- 97. Interleaving String
- 100. Same Tree
- 104. Maximum Depth of Binary Tree
- 115. Distinct Subsequences
- 120. Triangle
- 121. Buy and Sell Stock
- 123. Best Time to Buy and Sell Stock 3
- 124. Binary Tree Maximum Path Sum
- 125. Valid Palindrome
- 135. Candy
- 136. Single Number
- 139. Word Break
- 141. Linked List Cycle
- 144. Binary Tree Preorder Traversal
- 146. LRU Cache
- 151. Reverse Words in a String
- 162. Find Peak Element
- 169. Majority Element
- 188. Best Time to Buy and Sell Stock IV
- 192. Word Frequenc
- 193. Valid Phone Number
- 194. Transpose Fil
- 195. Tenth Lin
- 197. Rising Temperature
- 198. House Robber
- 199. Binary Tree Right Side View
- 200. Number of Islands
- 202. Happy Number
- 205. Isomorphic Strings
- 206. Reverse Linked List
- 208. Implement Trie (Prefix Tree)
- 215. Kth Largest Element in an Array
- 216. Combination Sum III
- 221. Maximal Square
- 236. Lowest Common Ancestor of a Binary Tree
- 238. Product of Array Except Self
- 242. Valid Anagram
- 279. Perfect Squares
- 283. Move Zeroes
- 300. Longest Increasing Subsequence
- 309. Best Time to Buy and Sell Stock with Cooldown
- 322. Coin Change
- 328. Odd Even Linked List
- 334. Increasing Triplet Subsequence
- 337. House Robber III
- 338. Counting Bits
- 342. Power of Four
- 343. Integer Break
- 345. Reverse Vowels of a String
- 354. Russian Doll Envelopes
- 368. Largest Divisible Subset
- 374. Guess Number Higher or Lower
- 383. Ransom Note
- 386. Lexicographical Numbers
- 392. Is Subsequence
- 394. Decode String
- 399. Evaluate Division
- 407. Trapping Rain Water II
- 415. Add Strings
- 416. Partition Equal Subset Sum
- 435. Non overlapping Intervals
- 437. Path Sum III
- 443. String Compression
- 450. Delete Node in a BST
- 452. Minimum Number of Arrows to Burst Balloons
- 455. Assign Cookies
- 474. Ones and Zeroes
- 494. Target Sum
- 509. Fibonacci Number
- 515. Find Largest Value in Each Tree Row
- 516. Longest Palindromic Subsequence
- 518. Coin Change II
- 547. Number of Provinces
- 570. Managers with at Least 5 Direct Reports
- 577. Employee Bonus
- 583. Delete Operation for Two Strings
- 584. Find Customer Referee
- 594. Longest Harmonious Subsequence
- 595. Big Countries
- 605. Can Place Flowers
- 620. Not Boring Movies
- 643. Maximum Average Subarray I
- 646. Maximum Length of Pair Chain
- 649. Dota2 Senate
- 673. Number of Longest Increasing Subsequence
- 684. Redundant Connection
- 689. Maximum Sum of 3 Non Overlapping Subarrays
- 700. Search in a Binary Search Tree
- 712. Minimum ASCII Delete Sum for Two Strings
- 714. Best Time to Buy and Sell Stock with Transaction Fee
- 717. 1 bit and 2 bit Characters
- 724. Find Pivot Index
- 735. Asteroid Collision
- 739. Daily Temperatures
- 740. Delete and Earn
- 746. Min Cost Climbing Stairs
- 756. Pyramid Transition Matrix
- 757. Set Intersection Size At Least Two
- 769. Max Chunks To Make Sorted
- 773. Sliding Puzzle
- 790. Domino and Tromino Tiling
- 802. Find Eventual Safe States
- 827. Making A Large Island
- 840. Magic Squares In Grid
- 841. Keys and Rooms
- 843. Guess the Word
- 865. Smallest Subtree with all the Deepest Nodes
- 872. Leaf Similar Trees
- 873. Length of Longest Fibonacci Subsequence
- 875. Koko Eating Bananas
- 889. Construct Binary Tree from Preorder and Postorder Traversal
- 901. Online Stock Span
- 916. Word Subsets
- 931. Minimum Falling Path Sum
- 933. Number of Recent Calls
- 944. Delete Columns to Make Sorted
- 960. Delete Columns to Make Sorted III
- 961. N Repeated Element in Size 2N Array
- 983. Minimum Cost For Tickets
- 994. Rotting Oranges
- 1004. Max Consecutive Ones III
- 1009. Complement of Base 10 Integer
- 1014. Best Sightseeing Pair
- 1015. Smallest Integer Divisible by K
- 1018. Binary Prefix Divisible By 5
- 1027. Longest Arithmetic Subsequence
- 1028. Recover a Tree From Preorder Traversal
- 1035. Uncrossed Lines
- 1068. Product Sales Analysis I
- 1070. Product Sales Analysis III
- 1071. Greatest Common Divisor of Strings
- 1072. Flip For Maximum Equal Rows
- 1079. Letter Tile Possibilities
- 1092. Shortest Common Supersequence
- 1123. Lowest Common Ancestor of Deepest Leaves
- 1137. N th Tribonacci Number
- 1143. Longest Common Subsequence
- 1148. Article Views I
- 1161. Maximum Level Sum of a Binary Tree
- 1207. Unique Number of Occurrences
- 1218. Longest Arithmetic Subsequence of Given Difference
- 1261. Find Elements in a Contaminated Binary Tree
- 1262. Greatest Sum Divisible by Three
- 1266. Minimum Time Visiting All Points
- 1267. Count Servers that Communicate
- 1268. Search Suggestions System
- 1290. Convert Binary Number in a Linked List to Integer
- 1295. Find Numbers with Even Number of Digits
- 1312. Minimum Insertion Steps to Make a String Palindrome
- 1318. Minimum Flips to Make a OR b Equal to c
- 1339. Maximum Product of Splitted Binary Tree
- 1346. Check If N and Its Double Exist
- 1351. Count Negative Numbers in a Sorted Matrix
- 1352. Product of the Last K Numbers
- 1358. Number of Substrings Containing All Three Characters
- 1368. Minimum Cost to Make at Least One Valid Path in a Grid
- 1372. Longest ZigZag Path in a Binary Tree
- 1378. Replace Employee ID With The Unique Identifier
- 1390. Four Divisors
- 1394. Find Lucky Integer in an Array
- 1399. Count Largest Group
- 1400. Construct K Palindrome Strings
- 1408. String Matching in an Array
- 1411. Number of Ways to Paint N × 3 Grid
- 1415. The kth Lexicographical String of All Happy Strings of Length n
- 1422. Maximum Score After Splitting a String
- 1431. Kids With the Greatest Number of Candies
- 1437. Check If All 1's Are at Least Length K Places Away
- 1448. Count Good Nodes in Binary Tree
- 1455. Check If a Word Occurs As a Prefix
- 1456. Maximum Number of Vowels in a Substring of Given Length
- 1458. Max Dot Product of Two Subsequences
- 1462. Course Schedule IV
- 1466. Reorder Routes to Make All Paths Lead to the City Zero
- 1475. Final Prices With a Special Discount in a Shop
- 1493. Longest Subarray of 1s After Deleting One Element
- 1513. Number of Substrings With Only 1s
- 1523. Count Odd Numbers in an Interval Range
- 1524. Number of Sub arrays With Odd Sum
- 1526. Minimum Number of Increments on Subarrays to Form a Target Array
- 1536. Minimum Swaps to Arrange a Binary Grid
- 1545. Find Kth Bit in Nth Binary String
- 1550. Three Consecutive Odds
- 1578. Minimum Time to Make Rope Colorful
- 1581. Customer Who Visited but Did Not Make Any Transactions
- 1582. Special Positions in a Binary Matrix
- 1590. Make Sum Divisible by P
- 1611. Minimum One Bit Operations to Make Integers Zero
- 1639. Number of Ways to Form a Target String Given a Dictionary
- 1652. Defuse the Bomb
- 1657. Determine if Two Strings Are Close
- 1661. Average Time of Process per Machine
- 1679. Max Number of K Sum Pairs
- 1683. Invalid Tweets
- 1689. Partitioning Into Minimum Number Of Deci Binary Numbers
- 1695. Maximum Erasure Value
- 1718. Construct the Lexicographically Largest Valid Sequence
- 1726. Tuple with Same Product
- 1732. Find the Highest Altitude
- 1749. Maximum Absolute Sum of Any Subarray
- 1752. Check if Array Is Sorted and Rotated
- 1757. Recyclable and Low Fat Products
- 1758. Minimum Changes To Make Alternating Binary String
- 1760. Minimum Limit of Balls in a Bag
- 1765. Map of Highest Peak
- 1768. Merge Strings Alternately
- 1769. Minimum Number of Operations to Move All Balls to Each Box
- 1780. Check if Number is a Sum of Powers of Three
- 1784. Check if Binary String Has at Most One Segment of Ones
- 1790. Check if One String Swap Can Make Strings Equal
- 1792. Maximum Average Pass Ratio
- 1800. Maximum Ascending Subarray Sum
- 1857. Largest Color Value in a Directed Graph
- 1861. Rotating the Box
- 1863. Sum of All Subset XOR Totals
- 1888. Minimum Number of Flips to Make the Binary String Alternating
- 1910. Remove All Occurrences of a Substring
- 1920. Build Array from Permutation
- 1925. Count Square Sum Triples
- 1926. Nearest Exit from Entrance in Maze
- 1930. Unique Length 3 Palindromic Subsequences
- 1934. Confirmation Rate
- 1964. Find the Longest Valid Obstacle Course at Each Position
- 1975. Maximum Matrix Sum
- 1980. Find Unique Binary String
- 2011. Final Value of Variable After Performing Operations
- 2016. Maximum Difference Between Increasing Elements
- 2017. Grid Game
- 2043. Simple Bank System
- 2054. Two Best Non Overlapping Events
- 2092. Find All People With Secret
- 2094. Finding 3 Digit Even Numbers
- 2095. Delete the Middle Node of a Linked List
- 2097. Valid Arrangement of Pairs
- 2109. Adding Spaces to a String
- 2110. Number of Smooth Descent Periods of a Stock
- 2116. Check if a Parentheses String Can Be Valid
- 2125. Number of Laser Beams in a Bank
- 2127. Maximum Employees to Be Invited to a Meeting
- 2130. Maximum Twin Sum of a Linked List
- 2138. Divide a String Into Groups of Size k
- 2140. Solving Questions With Brainpower
- 2141. Maximum Running Time of N Computers
- 2147. Number of Ways to Divide a Long Corridor
- 2154. Keep Multiplying Found Values by Two
- 2161. Partition Array According to Given Pivot
- 2169. Count Operations to Obtain Zero
- 2182. Construct String With Repeat Limit
- 2185. Counting Words With a Given Prefix
- 2206. Divide Array Into Equal Pairs
- 2211. Count Collisions on a Road
- 2215. Find the Difference of Two Arrays
- 2226. Maximum Candies Allocated to K Children
- 2257. Count Unguarded Cells
- 2270. Number of Ways to Split Array
- 2290. Minimum Obstacle Removal
- 2300. Successful Pairs of Spells and Potions
- 2336. Smallest Number in Infinite Set
- 2337. Move Pieces to Obtain a String
- 2342. Max Sum of a Pair With Equal Sum of Digits
- 2349. Design a Number Container System
- 2352. Equal Row and Column Pairs
- 2356. Number of Unique Subjects Taught by Each Teacher
- 2364. Count Number of Bad Pairs
- 2375. Construct Smallest Number From DI String
- 2379. Minimum Recolors to Get K Consecutive Black Blocks
- 2381. Shifting Letters II
- 2390. Removing Stars From a String
- 2401. Longest Nice Subarray
- 2402. Meeting Rooms III
- 2415. Reverse Odd Levels of Binary Tree
- 2425. Bitwise XOR of All Pairings
- 2429. Minimize XOR
- 2435. Paths in Matrix Whose Sum Is Divisible by K
- 2438. Range Product Queries of Powers
- 2460. Apply Operations to an Array
- 2461. Maximum Sum of Distinct Subarrays
- 2462. Total Cost to Hire K Workers
- 2466. Count Ways To Build Good Strings
- 2467. Most Profitable Path in a Tree
- 2471. Minimum Number of Operations to Sort a Binary Tree by Level
- 2483. Minimum Penalty for a Shop
- 2493. Divide Nodes Into the Maximum Number of Groups
- 2516. Take K of Each Character
- 2523. Closest Prime Numbers in Range
- 2528. Maximize the Minimum Powered City
- 2529. Maximum Count of Positive Integer and Negative Integer
- 2536. Increment Submatrices by One
- 2542. Maximum Subsequence Score
- 2554. Maximum Number of Integers to Choose From a Range
- 2558. Take Gifts From the Richest Pile
- 2559. Count Vowel Strings in Ranges
- 2560. House Robber IV
- 2566. Maximum Difference by Remapping a Digit
- 2570. Merge Two 2D Arrays by Summing Values
- 2577. Minimum Time to Visit a Cell
- 2579. Count Total Number of Colored Cells
- 2593. Find Score of an Array After Marking All Elements
- 2594. Minimum Time to Repair Cars
- 2654. Minimum Number of Operations to Make All Array Elements Equal to 1
- 2657. Find the Prefix Common Array of Two Arrays
- 2658. Maximum Number of Fish in a Grid
- 2661. First Completely Painted Row or Column
- 2683. Neighboring Bitwise XOR
- 2698. Find the Punishment Number of an Integer
- 2762. Continuous Subarrays
- 2779. Maximum Beauty of an Array After Applying Operation
- 2787. Ways to Express an Integer as Sum of Powers
- 2825. Make String a Subsequence Using Cyclic Increments
- 2872. Maximum Number of K Divisible Components
- 2873. Maximum Value of an Ordered Triplet I
- 2874. Maximum Value of an Ordered Triplet II
- 2894. Divisible and Non divisible Sums Difference
- 2924. Find Champion II
- 2940. Find Building Where Alice and Bob Can Meet
- 2942. Find Words Containing Character
- 2948. Make Lexicographically Smallest Array by Swapping Elements
- 2965. Find Missing and Repeated Values
- 2966. Divide Array Into Arrays With Max Difference
- 2981. Find Longest Special Substring That Occurs Thrice I
- 3042. Count Prefix and Suffix Pairs I
- 3066. Minimum Operations to Exceed Threshold Value II
- 3074. Apple Redistribution into Boxes
- 3075. Maximize Happiness of Selected Children
- 3105. Longest Strictly Increasing or Strictly Decreasing Subarray
- 3129. Find All Possible Stable Binary Arrays I
- 3136. Valid Word
- 3151. Special Array I
- 3152. Special Array II
- 3160. Find the Number of Distinct Colors Among the Balls
- 3169. Count Days Without Meetings
- 3170. Lexicographically Minimum String After Removing Stars
- 3174. Clear Digits
- 3190. Find Minimum Operations to Make All Elements Divisible by Three
- 3191. Minimum Operations to Make Binary Array Elements Equal to One I
- 3203. Find Minimum Diameter After Merging Two Trees
- 3208. Alternating Groups II
- 3217. Delete Nodes From Linked List Present in Array
- 3223. Minimum Length of String After Operations
- 3228. Maximum Number of Operations to Move Ones to the End
- 3234. Count the Number of Substrings With Dominant Ones
- 3243. Shortest Distance After Road Addition Queries I
- 3264. Final Array State After K Multiplication Operations I
- 3306. Count of Substrings Containing Every Vowel and K Consonants II
- 3318. Find X Sum of All K Long Subarrays I
- 3321. Find X Sum of All K Long Subarrays II
- 3330. Find the Original Typed String I
- 3346. Maximum Frequency of an Element After Performing Operations I
- 3349. Adjacent Increasing Subarrays Detection I
- 3354. Make Array Elements Equal to Zero
- 3356. Zero Array Transformation II
- 3370. Smallest Number With All Set Bits
- 3375. Minimum Operations to Make Array Values Equal to K
- 3381. Maximum Subarray Sum With Length Divisible by K
- 3392. Count Subarrays of Length Three With a Condition
- 3394. Check if Grid can be Cut into Sections
- 3396. Minimum Number of Operations to Make Elements in Array Distinct
- 3397. Maximum Number of Distinct Elements After Operations
- 3408. Design Task Manager
- 3417. Zigzag Grid Traversal With Skip
- 3418. Maximum Amount of Money Robot Can Earn
- 3423. Maximum Difference Between Adjacent Elements in a Circular Array
- 3432. Count Partitions with Even Sum Difference
- 3433. Count Mentions Per User
- 3442. Maximum Difference Between Even and Odd Frequency I
- 3453. Separate Squares I
- 3471. Find the Largest Almost Missing Integer
- 3472. Longest Palindromic Subsequence After at Most K Operations
- 3473. Sum of K Subarrays With Length at Least M
- 3474. Lexicographically Smallest Generated String
- 3477. Fruits Into Baskets II
- 3487. Maximum Unique Subarray Sum After Deletion
- 3488. Closest Equal Element Queries
- 3489. Zero Array Transformation IV
- 3512. Minimum Operations to Make Array Sum Divisible by K
- 3531. Count Covered Buildings
- 3541. Find Most Frequent Vowel and Consonant
- 3542. Minimum Operations to Convert All Elements to Zero
- 3562. Maximum Profit from Trading Stocks with Discounts
- 3573. Best Time to Buy and Sell Stock V
- 3577. Count the Number of Computer Unlocking Permutations
- 3578. Count Partitions With Max Min Difference at Most K
- 3583. Count Special Triplets
- 3606. Coupon Code Validator
- 3607. Power Grid Maintenance
- 3623. Count Number of Trapezoids I
- 3625. Count Number of Trapezoids II
- 3650. Minimum Cost Path with Edge Reversals
- 3652. Best Time to Buy and Sell Stock using Strategy