---
# System prepended metadata

title: LeetCode_Practice
tags: [leetcode]

---

# LeetCode_Practice
###### tags: `leetcode`
My LeetCode Practice started from 2020
## Preface
Trying to do Leetcode as my daily practice. Will update a solution with explaination.
## Array
### 27_Remove_element
https://hackmd.io/@eesss34690/Bywqxq9aD
### 26_Remove_Duplicates
https://hackmd.io/@eesss34690/rJ9Ljcqav
### 80_Remove_Duplicates_From_Sorted_Array_II
https://hackmd.io/@eesss34690/SyiEurpaw
### 189_Rotate_array
https://hackmd.io/@eesss34690/B19nstTav
### 41_First_Missing_Positive
https://hackmd.io/@eesss34690/BymEyjApv
### 299_Bulls_and_Cows
https://hackmd.io/@eesss34690/H1mohgxRD
### 134_Gas_Station
https://hackmd.io/@eesss34690/HJVwucWRw
### 118_Pascal's_Triangle_I
https://hackmd.io/@eesss34690/HJfXhYGRv
### 119_Pascal's_Triangle_II
https://hackmd.io/@eesss34690/rysSV9GRD
### 169_Majority_Element
https://hackmd.io/YvWqXfvJRjGXY2UhvTtB7w
### 229_Majority_Element_II
https://hackmd.io/BChXZQVCR52fl3hC2IUSJg
### 274_H_Index
https://hackmd.io/@eesss34690/B1aOsADAD
### 275_H_Index_II
https://hackmd.io/@eesss34690/SJnB99qCv
### 217_Contain_Duplicate
https://hackmd.io/@eesss34690/HJWUyViCD
### 55_Jump_Game
https://hackmd.io/@eesss34690/BJO-Mb2AP
### 45_Jump_Game_II
https://hackmd.io/@eesss34690/rJDGtUTAD
### 121_Best_Time_to_Buy_and_Sell_Stock
https://hackmd.io/@eesss34690/HkIfVwaAw
### 122_Best_Time_to_Buy_and_Sell_Stock_II
https://hackmd.io/@eesss34690/Sy57jvp0D
### 123_Best_Time_to_Buy_and_Sell_Stock_III
https://hackmd.io/@eesss34690/Sk1jDQHy_
## String
### 28_Implement_strStr()
https://hackmd.io/@eesss34690/B1_tffFJd
### 14_Longest_Common_Prefix
https://hackmd.io/@eesss34690/By9Mewqyd
### 58_Length_of_Last_Word
https://hackmd.io/@eesss34690/HJCtwDcyO
### 387_First_Unique_Character_in_a_String
https://hackmd.io/@eesss34690/ByVgGuqkd
### 383_Ransom_Note
https://hackmd.io/@eesss34690/rkKfh3oJO
### 344_Reverse_String
https://hackmd.io/@eesss34690/HJAvR3iyO
### 151_Reverse_Words_in_a_String
https://hackmd.io/@eesss34690/BJzIPpoJu
### 345_Reverse_Vowels_of_a_String
https://hackmd.io/@eesss34690/S1sBBgayu
### 205_Isomorphic_Strings
https://hackmd.io/@eesss34690/BJmZf-ayu
### 290_Word_Pattern
https://hackmd.io/@eesss34690/Byx3iLC1_
### 242_Valid_Anagram
https://hackmd.io/@eesss34690/Bylg7cklu
### 49_Group_Anagrams
https://hackmd.io/@eesss34690/SkoNRJZg_
### 38_Count_and_Say
https://hackmd.io/@eesss34690/BJ5dnt7x_
### 316_Remove_Duplicate_Letters
https://hackmd.io/@eesss34690/r1_BiAExd
### 168_Excel_Sheet_Column_Title
https://hackmd.io/@eesss34690/Sk7ZuX8eu
### 171_Excel_Sheet_Column_Number
https://hackmd.io/@eesss34690/ryY_ddDed
### 13_Roman_to_Integer
https://hackmd.io/@eesss34690/HJBNzFved
### 273_Integer_to_English_Words
https://hackmd.io/@eesss34690/rJ7Iygtl_v
### 68_Text_Justification
https://hackmd.io/@eesss34690/rkdzeaold
### 65_Valid_Number
https://hackmd.io/@eesss34690/r1wVtT3e_
### 76_Minimum_Window_Substring
https://hackmd.io/@eesss34690/rJxJhzAgu
### 30_Substring_with_Concatenation_of_All_Words
https://hackmd.io/@eesss34690/B1F0Qw1WO
### 165_Compare_Version_Numbers
https://hackmd.io/@eesss34690/BkezNt1Gu
### 66_Plus_One
https://hackmd.io/@eesss34690/By4GZIbfu
### 1561_Maximum_Number_of_Coins_You_Can_Get
https://hackmd.io/@eesss34690/HJk3jEGmO
### 365_Water_and_Jug_Problem
https://hackmd.io/@eesss34690/rJZUJh77O
### 144_Binary_Tree_Preorder_Traversal
https://hackmd.io/@eesss34690/rkUnRSiXu
### 94_Binary_Tree_Inorder_Traversal
https://hackmd.io/@eesss34690/r157mIiQd
### 145_Binary_Tree_Postorder_Traversal
https://hackmd.io/@eesss34690/rk8vkvjmu
### 102_Binary_Tree_Level_Order_Traversal
https://hackmd.io/@eesss34690/rJs9ewiQu

## Algorithm Practice
### 684_Redundant_Connection
https://hackmd.io/@eesss34690/BJNzcIQnd
### 315_Count_of_Smaller_Numbers_After_Self
https://hackmd.io/@eesss34690/Skqz_JL3u
### 135_Candy
https://hackmd.io/@eesss34690/r1R0nJU3u
### 1300_Sum_of_Mutated_Array_Closest_to_Target
https://hackmd.io/@eesss34690/B15NH-P3_
### 1047_Remove_All_Adjacent_Duplicates_In_String
https://hackmd.io/@eesss34690/S1DbqZvhd
### 1004_Max_Consecutive_Ones_III
https://hackmd.io/@eesss34690/BJ2-hnu2_
### 236_Lowest_Common_Ancestor_of_a_Binary_Tree
https://hackmd.io/@eesss34690/HkXqXe92_
### 89_Gray_Code
https://hackmd.io/@eesss34690/HyJisLi2d
### 658_Find_K_Closest_Elements
https://hackmd.io/@eesss34690/ryB6_86h_
### 363_Max_Sum_of_Rectangle_No_Larger_Than_K
https://hackmd.io/@eesss34690/Sy9cbx16d
### 1338_Reduce_Array_Size_to_The_Half
https://hackmd.io/@eesss34690/Sy8iI9WT_
### 378_Kth_Smallest_Element_in_a_Sorted_Matrix
https://hackmd.io/@eesss34690/BJ6Zf4XTO
### 718_Maximum_Length_of_Repeated_Subarray
https://hackmd.io/@eesss34690/HJ481OE6_
### 300_Longest_Increasing_Subsequence
https://hackmd.io/@eesss34690/SkvCHFU6_
### 639_Decode_Ways_II
https://hackmd.io/@eesss34690/rkPaJxdTu
### 295_Find_Median_from_Data_Stream
https://hackmd.io/@eesss34690/rJBlXNFpu
### 162_Find_Peak_Element
https://hackmd.io/@eesss34690/SJbZmCc6u
### 791_Custom_Sort_String
https://hackmd.io/@eesss34690/BJq9d_npO
### 611_Valid_Triangle_Number
https://hackmd.io/@eesss34690/Sy7HsvpaO
### 18_4Sum
https://hackmd.io/@eesss34690/HyIannJ0d
### 927_Three_Equal_Parts
https://hackmd.io/@eesss34690/BJTcw4eR_
### 25_Reverse_Nodes_in_k-Group
https://hackmd.io/@eesss34690/HJB8FYGAO
### 235_Lowest_Common_Ancestor_of_a_Binary_Search_Tree
https://hackmd.io/@eesss34690/BJv5Npf0u
### 384_Shuffle_an_Array
https://hackmd.io/@eesss34690/rkAY-W40O
### 838_Push_Dominoes
https://hackmd.io/@eesss34690/SkMb_CUA_
### 915_Partition_Array_into_Disjoint_Intervals
https://hackmd.io/@eesss34690/SJoPxywR_
### 814_Binary_Tree_Pruning
https://hackmd.io/@eesss34690/Sy00aIOCO
### 126_Word_Ladder_II
https://hackmd.io/@eesss34690/Hk4TPNcR_
### 600_Non-negative_Integers_without_Consecutive_Ones
https://hackmd.io/@eesss34690/HJtFo1iAd
### 16_3Sum_Closest
https://hackmd.io/@eesss34690/Skuynv6Cd
### 677_Map_Sum_Pairs
https://hackmd.io/@eesss34690/HJc684ZJt
### 42_Trapping_Rain_Water
https://hackmd.io/@eesss34690/HJxyNRMJY
### 827_Making_A_Large_Island
https://hackmd.io/@eesss34690/ryhkp-ckt
### 1_Two_Sum
https://hackmd.io/@eesss34690/rk-RVMqyK
### 90_Subsets_II
https://hackmd.io/@eesss34690/r1wGuzq1K
### 113_Path_Sum_II
https://hackmd.io/@eesss34690/HJAe9zc1t
### 877_Stone_Game
https://hackmd.io/@eesss34690/SkLqnzqyt
### 429_N-ary_Tree_Level_Order_Traversal
https://hackmd.io/@eesss34690/ByQ5Gu5kF
### 132_Palindrome Partitioning II
https://hackmd.io/@eesss34690/H11Gfhnyt
### 1632_Rank_Transform_of_a_Matrix
https://hackmd.io/@eesss34690/SJt4sIyxY
### 415_Add_Strings
https://hackmd.io/@eesss34690/SyJLBPkgF
### 926_Flip_String_to_Monotone_Increasing
https://hackmd.io/@eesss34690/SypEgCelt
### 954_Array_of_Doubled_Pairs
https://hackmd.io/@eesss34690/S1Hwab-lF
### 73_Set_Matrix_Zeroes
https://hackmd.io/@eesss34690/SJ-ilg8eK
### 546_Remove_Boxes
https://hackmd.io/@eesss34690/HkQ_mlIgF
### 303_Range_Sum_Query-Immutable
https://hackmd.io/@eesss34690/HJGq9nDxK
### 1448_Count_Good_Nodes_in_Binary_Tree
https://hackmd.io/@eesss34690/ByViKZtlt
### Decode_Ways
https://hackmd.io/@eesss34690/H1nIZvceK
### 36_Valid_Sudoku
https://hackmd.io/@eesss34690/rkORvWAgt
### 850_Rectangle_Area_II
https://hackmd.io/@eesss34690/S1jqZmkZt
### 653_TwoSum IV - Input is a BST
https://hackmd.io/@eesss34690/rJ2AqCgWK
### 537 Complex Number Multiplication
https://hackmd.io/@eesss34690/Bk26c7Mbt
### 633 Sum of Square Numbers
https://hackmd.io/@eesss34690/SJUp62rbK
### 331 Verify Preorder Serialization of a Binary Tree
https://hackmd.io/@eesss34690/Sy4ap3BZt
### 1235 Maximum Profit in Job Scheduling
https://hackmd.io/@eesss34690/HyfJjvdbY
### 598 Range Addition II
https://hackmd.io/@eesss34690/HyfEJwsZK
### 153 Find Minimum in Rotated
https://hackmd.io/@eesss34690/r1QpiUs-Y
### 565 Array Nesting
https://hackmd.io/@eesss34690/HyHUza6Wt
### 95 Unique Binary Search Trees II
https://hackmd.io/@eesss34690/HyBODrezF
### 587 Erect the Fence
https://hackmd.io/@eesss34690/B1xkYSxGF
### 834 Sum of Distances in Tree
https://hackmd.io/@eesss34690/r1HCgj-ft
### 899 Orderly Queue
https://hackmd.io/@eesss34690/B1vAUI4fF
### 1629 Slowest Key
https://hackmd.io/@eesss34690/HJ21S8VGF
### 206 Reverse Linked List
https://hackmd.io/@eesss34690/H1o6ZNLfF
### 848 Shifting Letters
https://hackmd.io/@eesss34690/BJZI4VLzY
### 764 Largest Plus Sign
https://hackmd.io/@eesss34690/HkuZ95vzt
### 446 Arithmetic Slices II - Subsequence
https://hackmd.io/@eesss34690/r1-flouGK
### 224 Basic Calculator
https://hackmd.io/@eesss34690/r1SRCT5fK
### 1834. Single-Threaded CPU
https://hackmd.io/@eesss34690/Hy4l74jto
### 797. All Paths From Source to Target
https://hackmd.io/@eesss34690/Bk0GdOhYo
### 980. Unique Paths III
https://hackmd.io/@eesss34690/r15HpHCFs
### 129. Sum Root to Leaf Numbers
https://hackmd.io/@eesss34690/r18vp8CKs
### 149. Max Points on a Line
https://hackmd.io/@eesss34690/rkbZg8u9o
### 100. Same Tree
https://hackmd.io/@eesss34690/HkHfLv55j
### 1443. Minimum Time to Collect All Apples in a Tree
https://hackmd.io/@eesss34690/S1zAl9iqs
### 1519. Number of Nodes in the Sub-Tree With the Same Label
https://hackmd.io/@eesss34690/H1BpJ_6cj
### 2246. Longest Path With Different Adjacent Characters
https://hackmd.io/@eesss34690/Sy_u7405j
### 2421. Number of Good Paths
https://hackmd.io/@eesss34690/BkXnfMfji
### 1162. As Far from Land as Possible
https://hackmd.io/@eesss34690/SJeANNXTj
#### 2477. Minimum Fuel Cost to Report to the Capital
https://hackmd.io/@eesss34690/B1qWpe8ao
### 104. Maximum Depth of Binary Tree
https://hackmd.io/@eesss34690/rJWZaeiaj
### 783. Minimum Distance Between BST Nodes
https://hackmd.io/@eesss34690/ryaQFB3To
### 226. Invert Binary Tree
https://hackmd.io/@eesss34690/HyFRcj66s
### 72. Edit Distance
https://hackmd.io/@eesss34690/BkiE94_Ao
### 427. Construct Quad Tree
https://hackmd.io/@eesss34690/rymGhyq0j
### 652. Find Duplicate Subtrees
https://hackmd.io/@eesss34690/B1uW-R5Ai
### 912. Sort an Array
https://hackmd.io/@eesss34690/BkcDhr3Cs
### 1992. Find All Groups of Farmland
https://hackmd.io/@eesss34690/SJHYGyJk2
### 2444. Count Subarrays With Fixed Bounds
https://hackmd.io/@eesss34690/S1Ve_4e1h
### 1345. Jump Game IV
https://hackmd.io/@eesss34690/r1voQw-12
### 2187. Minimum Time to Complete Trips
https://hackmd.io/@eesss34690/Sk0lYzNyh
### 142. Linked List Cycle II
https://hackmd.io/@eesss34690/BkDLH28kh
### 109. Convert Sorted List to Binary Search Tree
https://hackmd.io/@eesss34690/HJV_UUFk2
### 23. Merge k Sorted Lists
https://hackmd.io/@eesss34690/BkYDps5J2
### 106. Construct Binary Tree from Inorder and Postorder Traversal
https://hackmd.io/@eesss34690/r1VacJegn
### 211. Design Add and Search Words Data Structure
https://hackmd.io/@eesss34690/SkpVqxNe2
### 2492. Minimum Score of a Path Between Two Cities
https://hackmd.io/@eesss34690/BJC-L8den
### 1319. Number of Operations to Make Network Connected
https://hackmd.io/@eesss34690/B16DwXFen
### 1466. Reorder Routes to Make All Paths Lead to the City Zero
https://hackmd.io/@eesss34690/H16DGO9g3
### 2316. Count Unreachable Pairs of Nodes in an Undirected Gra### ph
https://hackmd.io/@eesss34690/BJC4wAog2
### 2360. Longest Cycle in a Graph
https://hackmd.io/@eesss34690/r1izcm6lh
### 64. Minimum Path Sum
https://hackmd.io/@eesss34690/SyNVvuAen
### 983. Minimum Cost For Tickets
https://hackmd.io/@eesss34690/BJZngaJW3
### 1402. Reducing Dishes
https://hackmd.io/@eesss34690/HkadlG-Z2
### 87. Scramble String
https://hackmd.io/@eesss34690/SydWctM-3
### 2300. Successful Pairs of Spells and Potions
https://hackmd.io/@eesss34690/SJ8ttPUZh
### 2439. Minimize Maximum of Array
https://hackmd.io/@eesss34690/ryrq5tqZ2
### 1254. Number of Closed Islands
https://hackmd.io/@eesss34690/ryiYXnoZ3
### 133. Clone Graph
https://hackmd.io/@eesss34690/ry_N7HC-2
### 1857. Largest Color Value in a Directed Graph
https://hackmd.io/@eesss34690/H1CGYcJG2
### 71. Simplify Path
https://hackmd.io/@eesss34690/SyeWQKmM3
### 516. Longest Palindromic Subsequence
https://hackmd.io/@eesss34690/BkyJPwwMh
### 2218. Maximum Value of K Coins From Piles
https://hackmd.io/@eesss34690/SJCKCYwfh
### 1639. Number of Ways to Form a Target String Given a Dictionary
https://hackmd.io/@eesss34690/Sk4JbXqzh
### 1372. Longest ZigZag Path in a Binary Tree
https://hackmd.io/@eesss34690/H1k5xahM3
### 662. Maximum Width of Binary Tree
https://hackmd.io/@eesss34690/By9y6f0Mh
### 1312. Minimum Insertion Steps to Make a String Palindrome
https://hackmd.io/@eesss34690/ry1mp2lmn
### 1416. Restore The Array
https://hackmd.io/@eesss34690/SkCHmZMm2
### 1046. Last Stone Weight
https://hackmd.io/@eesss34690/r133YBQmn
### 2336. Smallest Number in Infinite Set
https://hackmd.io/@eesss34690/HyrUWoN7n
### 258. Add Digits
https://hackmd.io/@eesss34690/BkGehOI72
### 839. Similar String Groups
https://hackmd.io/@eesss34690/BkU5eqd72
### 1697. Checking Existence of Edge Length Limited Paths
https://hackmd.io/@eesss34690/r1xKBZ5Qh
### 1579. Remove Max Number of Edges to Keep Graph Fully Traversable
https://hackmd.io/@eesss34690/BJUh1SiQ3
### 1491. Average Salary Excluding the Minimum and Maximum Salary
https://hackmd.io/@eesss34690/H11qq5372
### 649. Dota2 Senate
https://hackmd.io/@eesss34690/r1aAW6lN3
### 1964. Find the Longest Valid Obstacle Course at Each Position
https://hackmd.io/@eesss34690/rJvs9R442
### 54. Spiral Matrix
https://hackmd.io/@eesss34690/ryeCJmD42
### 59. Spiral Matrix II
https://hackmd.io/@eesss34690/BJxWMPOEn
### 1035. Uncrossed Lines
https://hackmd.io/@eesss34690/HJbRbpFE2
### 2140. Solving Questions With Brainpower
https://hackmd.io/@eesss34690/SJQAR-o43
### 2466. Count Ways To Build Good Strings
https://hackmd.io/@eesss34690/BJn9eP3Eh
### 1799. Maximize Score After N Operations
https://hackmd.io/@eesss34690/S1kx03pN2
### 1721. Swapping Nodes in a Linked List
https://hackmd.io/@eesss34690/ry2d7HJSh
### 1140. Stone Game II
https://hackmd.io/@eesss34690/SJiqpt6S3
### 1406. Stone Game III
https://hackmd.io/@eesss34690/ry3ye1JI3
### 1547. Minimum Cost to Cut a Stick
https://hackmd.io/@eesss34690/HJhCOQgLn
### 1396. Design Underground System
https://hackmd.io/@eesss34690/Hy2V3H4Ln
### 1091. Shortest Path in Binary Matrix
https://hackmd.io/@eesss34690/BJbUGqHLn
### 2101. Detonate the Maximum Bombs
https://hackmd.io/@eesss34690/ByhiIpU83
### 1376. Time Needed to Inform All Employees
https://hackmd.io/@eesss34690/r1TXJzd83
### 547. Number of Provinces
https://hackmd.io/@eesss34690/r1u-fgi8n
### 1802. Maximum Value at a Given Index in a Bounded Array
https://hackmd.io/@eesss34690/r1cfpI-vh
### 1146. Snapshot Array
https://hackmd.io/@eesss34690/rJ3ebjGDn
### 1161. Maximum Level Sum of a Binary Tree
https://hackmd.io/@eesss34690/S1um_RwDn
### 1569. Number of Ways to Reorder Array to Get Same BST
https://hackmd.io/@eesss34690/SJddDVFPh
### 1187. Make Array Strictly Increasing
https://hackmd.io/@eesss34690/Hkn46Y5vh
### 2328. Number of Increasing Paths in a Grid
https://hackmd.io/@eesss34690/rkciounwn
### 2090. K Radius Subarray Averages
https://hackmd.io/@eesss34690/HylP4_AD3
### 2448. Minimum Cost to Make Array Equal
https://hackmd.io/@eesss34690/HJKs7ayd2
### 1027. Longest Arithmetic Subsequence
https://hackmd.io/@eesss34690/H10xCufuh
### 956. Tallest Billboard
https://hackmd.io/@eesss34690/H1gTpCm_3
### 1575. Count All Possible Routes
https://hackmd.io/@eesss34690/B1FkfzH_3
### 2462. Total Cost to Hire K Workers
https://hackmd.io/@eesss34690/HkgkMDL_2
### 373. Find K Pairs with Smallest Sums
https://hackmd.io/@eesss34690/BkJNanP_h
### 1514. Path with Maximum Probability
https://hackmd.io/@eesss34690/HJyO3t9u2
### 864. Shortest Path to Get All Keys
https://hackmd.io/@eesss34690/rkMggqqu2
### 2305. Fair Distribution of Cookies
https://hackmd.io/@eesss34690/SJ-gVbadn
### 1601. Maximum Number of Achievable Transfer Requests
https://hackmd.io/@eesss34690/H1QqdD0un
### 209. Minimum Size Subarray Sum
https://hackmd.io/@eesss34690/SJbgPkWKn
### 2024. Maximize the Confusion of an Exam
https://hackmd.io/@eesss34690/S15UoyrKh
### 2551. Put Marbles in Bags 
https://hackmd.io/@eesss34690/rkJGb8Lth
### 2272. Substring With Largest Variance
https://hackmd.io/@eesss34690/rynsD9PF2
### 863. All Nodes Distance K in Binary Tree
https://hackmd.io/@eesss34690/SyB5qviYh
### 802. Find Eventual Safe States
https://hackmd.io/@eesss34690/r1UQTdotn
