Git Product home page Git Product logo

leetcodepractice's Introduction

Solutions to Leetcode Challenges

This repository contains my solutions to LeetCode practice problems.

Algorithms

ID Challenge Solution
001 Two Sum Solution
002 Add Two Numbers Solution
003 Longest Substring Without Repeating Characters Solution
005 Longest Palindromic Substring Solution
007 Reverse Integer Solution
009 Palindrome Number Solution
011 Container With Most Water Solution
012 Integer to Roman Solution
013 Roman to Integer Solution
014 Longest Common Prefix Solution
017 Letter Combinations of a Phone Number Solution
021 Merge Two Sorted Lists Solution
22 Generate Parentheses Solution
023 Merge k Sorted Lists Solution
026 Remove Duplicates from Sorted Array Solution
027 Remove Element Solution
028 Implement strStr Solution
034 Find First and Last Position of Element in Sorted Array Solution
035 Search Insert Position Solution
038 Count and Say Solution
039 Combination Sum Solution
040 Combination Sum II Solution
046 Permutations Solution
053 Maximum Subarray Solution
55 Jump Game Solution
058 Length of Last Word Solution
62 Unique Paths Solution
066 Plus One Solution
067 Add Binary Solution
069 Sqrtx Solution
070 Climbing Stairs Solution
077 Combinations Solution
078 Subsets Solution
083 Remove Duplicates from Sorted List Solution
088 Merge Sorted Array Solution
090 Subsets II Solution
94 Binary Tree Inorder Traversal Solution
100 Same Tree Solution
101 Symmetric Tree Solution
102 Binary Tree Level Order Traversal Solution
104 Maximum Depth of Binary Tree Solution
110 Balanced Binary Tree Solution
111 Minimum Depth of Binary Tree Solution
112 Path Sum Solution
113 Path Sum ii Solution
118 Pascal Solution
119 Pascal Solution
121 Best Time to Buy and Sell Stock Solution
122 Best Time to Buy and Sell Stock II Solution
125 Valid Palindrome Solution
128 Longest Consecutive Sequence Solution
136 Single Number Solution
137 Single Number II Solution
139 Word Break Solution
141 Linked List Cycle Solution
144 Binary Tree Preorder Traversal Solution
145 Binary Tree Postorder Traversal Solution
151 Reverse Words in a String Solution
152 Maximum Product Subarray Solution
153 Find Minimum in Rotated Sorted Array Solution
160 Intersection of Two Linked Lists Solution
167 Two Sum II - Input array is sorted Solution
168 Excel Sheet Column Title Solution
169 Majority Element Solution
171 Excel Sheet Column Number Solution
172 Factorial Trailing Zeroes Solution
175 Combine Two Tables Solution
176 Second Highest Salary Solution
177 Nth Highest Salary Solution
178 Rank Scores Solution
181 Employees Earning More Than Their Managers Solution
182 Duplicate Emails Solution
183 Customers Who Never Order Solution
189 Rotate Array Solution
190 Reverse Bits Solution
191 Number of 1 Bits Solution
192 Word Frequency Solution
193 Valid Phone Numbers Solution
195 Tenth Line Solution
196 Delete Duplicate Emails Solution
197 Rising Temperature Solution
198 House Robber Solution
202 Happy Number Solution
203 Remove Linked List Elements Solution
204 Count Primes Solution
206 Reverse Linked List Solution
216 Combination Sum III Solution
217 Contains Duplicate Solution
219 Contains Duplicate II Solution
223 Rectangle Area Solution
226 Invert Binary Tree Solution
228 Summary Ranges Solution
231 Power of Two Solution
237 Delete Node in a Linked List Solution
238 Product of Array Except Self Solution
242 Valid Anagram Solution
257 Binary Tree Paths Solution
258 Add Digits Solution
263 Ugly Number Solution
264 Ugly Number II Solution
268 Missing Number Solution
278 First Bad Version Solution
283 Move Zeroes Solution
287 Find the Duplicate Number Solution
290 Word Pattern Solution
292 Nim Game Solution
322 Coin Change Solution
326 Power of Three Solution
338 Counting Bits Solution
342 Power of Four Solution
343 Integer Break Solution
344 Reverse String Solution
345 Reverse Vowels of a String Solution
347 Top K Frequent Elements Solution
349 Intersection of Two Arrays Solution
350 Intersection of Two Arrays II Solution
367 Valid Perfect Square Solution
374 Guess Number Higher or Lower Solution
383 Ransom Note Solution
387 First Unique Character in a String Solution
389 Find the Difference Solution
392 Is Subsequence Solution
404 Sum of Left Leaves Solution
405 Convert a Number to Hexadecimal Solution
409 Longest Palindrome Solution
412 Fizz Buzz Solution
414 Third Maximum Number Solution
415 Add Strings Solution
434 Number of Segments in a String Solution
441 Arranging Coins Solution
448 Find All Numbers Disappeared in an Array Solution
453 Minimum Moves to Equal Array Elements Solution
492 Construct the Rectangle Solution
495 Teemo Attacking Solution
504 Base 7 Solution
506 Relative Ranks Solution
509 Fibonacci Number Solution
511 Game Play Analysis I Solution
520 Detect Capital Solution
521 Longest Uncommon Subsequence I Solution
537 Complex Number Multiplication Solution
539 Minimum Time Difference Solution
541 Reverse String II Solution
551 Student Attendance Record I Solution
557 Reverse Words in a String III Solution
561 Array Partition I Solution
566 Reshape the Matrix Solution
586 Customer Placing the Largest Number of Orders Solution
593 Valid Square Solution
595 Big Countries Solution
605 Can Place Flowers Solution
607 Sales Person Solution
617 Merge Two Binary Trees Solution
620 Not Boring Movies Solution
627 Swap Salary Solution
628 Maximum Product of Three Numbers Solution
637 Average of Levels in Binary Tree Solution
643 Maximum Average Subarray I Solution
648 Replace Words Solution
657 Robot Return to Origin Solution
674 Longest Continuous Increasing Subsequence Solution
682 Baseball Game Solution
693 Binary Number with Alternating Bits Solution
696 Count Binary Substrings Solution
704 Binary Search Solution
707 Design Linked List Solution
709 To Lower Case Solution
719 Find K-th Smallest Pair Distance Solution
724 Find Pivot Index Solution
728 Self Dividing Numbers Solution
729 My Calendar I Solution
744 Find Smallest Letter Greater Than Target Solution
746 Min Cost Climbing Stairs Solution
747 Largest Number At Least Twice of Others Solution
748 Shortest Completing Word Solution
762 Prime Number of Set Bits in Binary Representation Solution
763 Partition Labels Solution
766 Toeplitz Matrix Solution
771 Jewels and Stones Solution
788 Rotated Digits Solution
792 Number of Matching Subsequences Solution
796 Rotate String Solution
804 Unique Morse Code Words Solution
806 Number of Lines To Write String Solution
812 Largest Triangle Area Solution
819 Most Common Word Solution
821 Shortest Distance to a Character Solution
824 Goat Latin Solution
830 Positions of Large Groups Solution
832 Flipping an Image Solution
836 Rectangle Overlap Solution
844 Backspace String Compare Solution
848 Shifting Letters Solution
852 Peak Index in a Mountain Array Solution
859 Buddy Strings Solution
860 Lemonade Change Solution
867 Transpose Matrix Solution
868 Binary Gap Solution
876 Middle of the Linked List Solution
884 Uncommon Words from Two Sentences Solution
894 All Possible Full Binary Trees Solution
896 Monotonic Array Solution
905 Sort Array By Parity Solution
908 Smallest Range I Solution
914 X of a Kind in a Deck of Cards Solution
916 Word Subsets Solution
917 Reverse Only Letters Solution
921 Minimum Add to Make Parentheses Valid Solution
922 Sort Array By Parity II Solution
929 Unique Email Addresses Solution
941 Valid Mountain Array Solution
942 DI String Match Solution
944 Delete Columns to Make Sorted Solution
961 N-Repeated Element in Size 2N Array Solution
976 Largest Perimeter Triangle Solution
977 Squares of a Sorted Array Solution
984 String Without AAA or BBB Solution
985 Sum of Even Numbers After Queries Solution
989 Add to Array-Form of Integer Solution
997 Find the Town Judge Solution
1002 Find Common Characters Solution
1006 Clumsy Factorial Solution
1009 Complement of Base 10 Integer Solution
1013 Partition Array Into Three Parts With Equal Sum Solution
1018 Binary Prefix Divisible By 5 Solution
1025 Divisor Game Solution
1030 Matrix Cells in Distance Order Solution
1043 Partition Array for Maximum Sum Solution
1047 Remove All Adjacent Duplicates In String Solution
1137 N-th Tribonacci Number Solution
1154 Day of the Year Solution
1160 Find Words That Can Be Formed by Characters Solution
1185 Day of the Week Solution
1189 Maximum Number of Balloons Solution
1201 Ugly Number III Solution
1237 Find Positive Integer Solution for a Given Equation Solution
1268 Search Suggestions System Solution
1277 Count Square Submatrices with All Ones Solution
1283 Find the Smallest Divisor Given a Threshold Solution
1287 Element Appearing More Than 25 Solution
1290 Convert Binary Number in a Linked List to Integer Solution
1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold Solution
1380 Lucky Numbers in a Matrix Solution
1385 Find the Distance Value Between Two Arrays Solution
1472 Design Browser History Solution
1556 Thousand Separator Solution
1646 Get Maximum in Generated Array Solution
1721 Swapping Nodes in a Linked List Solution
1732 Find the Highest Altitude Solution
1752 Check if Array Is Sorted and Rotated Solution
1758 Minimum Changes To Make Alternating Binary String Solution
1763 Longest Nice Substring Solution
1768 Merge Strings Alternately Solution
1773 Count Items Matching a Rule Solution
1779 Find Nearest Point That Has the Same X or Y Coordinate Solution
1796 Second Largest Digit in a String Solution
1812 Determine Color of a Chessboard Square Solution
1816 Truncate Sentence Solution
1822 Sign of the Product of an Array Solution
1823 Find the Winner of the Circular Game Solution
1837 Sum of Digits in Base K Solution
1844 Replace All Digits with Characters Solution
1848 Minimum Distance to the Target Element Solution
1859 Sorting the Sentence Solution
1869 Longer Contiguous Segments of Ones than Zeros Solution
1876 Substrings of Size Three with Distinct Characters Solution
1880 Check if Word Equals Summation of Two Words Solution
1886 Determine Whether Matrix Can Be Obtained By Rotation Solution
1893 Check if All the Integers in a Range Are Covered Solution
1897 Redistribute Characters to Make All Strings Equal Solution
1903 Largest Odd Number in String Solution
1909 Remove One Element to Make the Array Strictly Increasing Solution
1913 Maximum Product Difference Between Two Pairs Solution
1920 Build Array from Permutation Solution
1925 Count Square Sum Triples Solution
1929 Concatenation of Array Solution
1935 Maximum Number of Words You Can Type Solution
1941 Check if All Characters Have Equal Number of Occurrences Solution
1945 Sum of Digits of String After Convert Solution
1952 Three Divisors Solution
1957 Delete Characters to Make Fancy String Solution
1961 Check If String Is a Prefix of Array Solution
1965 Employees With Missing Information Solution
1967 Number of Strings That Appear as Substrings in Word Solution
1974 Minimum Time to Type Word Using Special Typewriter Solution
1980 Find Unique Binary String Solution
1991 Find the Middle Index in Array Solution
2000 Reverse Prefix of Word Solution
2006 Count Number of Pairs With Absolute Difference K Solution
2011 Final Value of Variable After Performing Operations Solution
2016 Maximum Difference Between Increasing Elements Solution
2022 Convert 1D Array Into 2D Array Solution
2023 Number of Pairs of Strings With Concatenation Equal to Target Solution
2042 Check if Numbers Are Ascending in a Sentence Solution
2047 Number of Valid Words in a Sentence Solution
2053 Kth Distinct String in an Array Solution
2057 Smallest Index With Equal Value Solution
2068 Check Whether Two Strings are Almost Equivalent Solution
2073 Time Needed to Buy Tickets Solution
2078 Two Furthest Houses With Different Colors Solution
2079 Watering Plants Solution
2085 Count Common Words With One Occurrence Solution
2089 Find Target Indices After Sorting Array Solution
2094 Finding 3-Digit Even Numbers Solution
2099 Find Subsequence of Length K With the Largest Sum Solution
2103 Rings and Rods Solution
2108 Find First Palindromic String in the Array Solution
2114 Maximum Number of Words Found in Sentences Solution
2119 A Number After a Double Reversal Solution
2124 Check if All As Appears Before All Bs Solution
2129 Capitalize the Title Solution
2130 Maximum Twin Sum of a Linked List Solution
2133 Check if Every Row and Column Contains All Numbers Solution
2138 Divide a String Into Groups of Size k Solution
2144 Minimum Cost of Buying Candies With Discount Solution
2148 Count Elements With Strictly Smaller and Greater Elements Solution
2149 Rearrange Array Elements by Sign Solution
2154 Keep Multiplying Found Values by Two Solution
2155 All Divisions With the Highest Score of a Binary Array Solution
2160 Minimum Sum of Four Digit Number After Splitting Digits Solution
2164 Sort Even and Odd Indices Independently Solution
2169 Count Operations to Obtain Zero Solution
2176 Count Equal and Divisible Pairs in an Array Solution
2180 Count Integers With Even Digit Sum Solution
2181 Merge Nodes in Between Zeros Solution
2185 Counting Words With a Given Prefix Solution
2190 Most Frequent Number Following Key In an Array Solution
2194 Cells in a Range on an Excel Sheet Solution
2200 Find All K-Distant Indices in an Array Solution
2206 Divide Array Into Equal Pairs Solution
2210 Count Hills and Valleys in an Array Solution
2215 Find the Difference of Two Arrays Solution
2220 Minimum Bit Flips to Convert Number Solution
2221 Find Triangular Sum of an Array Solution
2224 Minimum Number of Operations to Convert Time Solution
2231 Largest Number After Digit Swaps by Parity Solution
2232 Minimize Result by Adding Parentheses to Expression Solution
2235 Add Two Integers Solution
2236 Root Equals Sum of Children Solution
2239 Find Closest Number to Zero Solution
2240 Number of Ways to Buy Pens and Pencils Solution
2243 Calculate Digit Sum of a String Solution
2248 Intersection of Multiple Arrays Solution
2255 Count Prefixes of a Given String Solution
2259 Remove Digit From Number to Maximize Result Solution
2264 Largest 3-Same-Digit Number in String Solution
2269 Find the K-Beauty of a Number Solution
2278 Percentage of Letter in String Solution
2283 Check if Number Has Equal Digit Count and Digit Value Solution
2287 Rearrange Characters to Make Target String Solution
2293 Min Max Game Solution
2299 Strong Password Checker ii Solution
2303 Calculate Amount Paid in Taxes Solution
2309 Greatest English Letter in Upper and Lower Case Solution
2315 Count Asterisks Solution
2319 Check if Matrix Is X-Matrix Solution
2325 Decode the Message Solution
2326 Spiral Matrix IV Solution
2331 Evaluate Boolean Binary Tree Solution
2335 Minimum Amount of Time to Fill Cups Solution
2341 Maximum Number of Pairs in Array Solution
2347 Best Poker Hand Solution
2351 First Letter to Appear Twice Solution
2352 Equal Row and Column Pairs Solution
2357 Make Array Zero by Subtracting Equal Amounts Solution
2358 Maximum Number of Groups Entering a Competition Solution
2363 Merge Similar Items Solution
2367 Number of Arithmetic Triplets Solution
2373 Largest Local Values in a Matrix Solution
2379 Minimum Recolors to Get K Consecutive Black Blocks Solution
2389 Longest Subsequence With Limited Sum Solution
2395 Find Subarrays With Equal Sum Solution
2399 Check Distances Between Same Letters Solution
2405 Optimal Partition of String Solution
2409 Count Days Spent Together Solution
2413 Smallest Even Multiple Solution
2415 Reverse Odd Levels of Binary Tree Solution
2418 Sort the People Solution
2433 Find The Original Array of Prefix Xor Solution
2441 Largest Positive Integer That Exists With Its Negative Solution
2442 Count Number of Distinct Integers After Reverse Operations Solution
2446 Determine if Two Events Have Conflict Solution
2452 Words Within Two Edits of Dictionary Solution
2455 Average Value of Even Numbers That Are Divisible by Three Solution
2460 Apply Operations to an Array Solution
2465 Number of Distinct Averages Solution
2469 Convert the Temperature Solution
2475 Number of Unequal Triplets in Array Solution
2481 Minimum Cuts to Divide a Circle Solution
2482 Difference Between Ones and Zeros in Row and Column Solution
2485 Find the Pivot Integer Solution
2486 Append Characters to String to Make Subsequence Solution
2487 Remove Nodes From Linked List Solution
2490 Circular Sentence Solution
2496 Maximum Value of a String in an Array Solution
2500 Delete Greatest Value in Each Row Solution
2506 Count Pairs Of Similar Strings Solution
2507 Smallest Value After Replacing With Sum of Prime Factors Solution
2515 Shortest Distance to Target String in a Circular Array Solution
2520 Count the Digits That Divide a Number Solution
2525 Categorize Box According to Criteria Solution
2529 Maximum Count of Positive Integer and Negative Integer Solution
2535 Difference Between Element Sum and Digit Sum of an Array Solution
2540 Minimum Common Value Solution
2544 Alternating Digit Sum Solution
2545 Sort the Students by Their Kth Score Solution
2549 Count Distinct Numbers on Board Solution
2553 Separate the Digits in an Array Solution
2554 Maximum Number of Integers to Choose From a Range I Solution
2558 Take Gifts From the Richest Pile Solution
2559 Count Vowel Strings in Ranges Solution
2562 Find the Array Concatenation Value Solution
2566 Maximum Difference by Remapping a Digit Solution
2570 Merge Two 2D Arrays by Summing Values Solution
2571 Minimum Operations to Reduce an Integer to 0 Solution
2574 Left and Right Sum Differences Solution
2578 Split With Minimum Sum Solution
2579 Count Total Number of Colored Cells Solution
2582 Pass the Pillow Solution
2586 Count the Number of Vowel Strings in Range Solution
2595 Number of Even and Odd Bits Solution
2600 K Items With the Maximum Sum Solution
2605 Form Smallest Number From Two Digit Arrays Solution
2609 Find the Longest Balanced Substring of a Binary String Solution
2610 Convert an Array Into a 2D Array With Conditions Solution
2614 Prime In Diagonal Solution
2639 Find the Width of Columns of a Grid Solution
2644 Find the Maximum Divisibility Score Solution
2651 Calculate Delayed Arrival Time Solution
2652 Sum Multiples Solution
2656 Maximum Sum With Exactly K Elements Solution
2657 Find the Prefix Common Array of Two Arrays Solution
2660 Determine the Winner of a Bowling Game Solution
2670 Find the Distinct Difference Array Solution
2678 Number of Senior Citizens Solution
2697 Lexicographically Smallest Palindrome Solution
2706 Buy Two Chocolates Solution
2710 Remove Trailing Zeros From a String Solution
2716 Minimize String Length Solution
2717 Semi-Ordered Permutation Solution
2729 Check if The Number is Fascinating Solution
2733 Neither Minimum nor Maximum Solution
2739 Total Distance Traveled Solution
2744 Find Maximum Number of String Pairs Solution
2748 Number of Beautiful Pairs Solution
2765 Longest Alternating Subarray Solution
2769 Find the Maximum Achievable Number Solution
2778 Sum of Squares of Special Elements Solution
2785 Sort Vowels in a String Solution
2788 Split Strings by Separator Solution
2798 Number of Employees Who Met the Target Solution
2806 Account Balance After Rounded Purchase Solution
2807 Insert Greatest Common Divisors in Linked List Solution
2810 Faulty Keyboard Solution
2815 Max Pair Sum in an Array Solution
2824 Count Pairs Whose Sum is Less than Target Solution
2828 Check if a String Is an Acronym of Words Solution
2833 Furthest Point From Origin Solution
2843 Count Symmetric Integers Solution
2848 Points That Intersect With Cars Solution
2855 Minimum Right Shifts to Sort the Array Solution
2859 Sum of Values at Indices With K Set Bits Solution
2864 Maximum Odd Binary Number Solution
2869 Minimum Operations to Collect Elements Solution
2873 Maximum Value of an Ordered Triplet Solution
2903 Find Indices With Index and Value Difference I Solution
2908 Minimum Sum of Mountain Triplets I Solution
2913 Subarrays Distinct Element Sum of Squares I Solution
2917 Find the K-or of an Array Solution
2923 Find Champion I Solution
2928 Distribute Candies Among Children I Solution
2937 Make Three Strings Equal Solution
2942 Find Words Containing Character Solution
2946 Matrix Similarity After Cyclic Shifts Solution
2951 Find the Peaks Solution
2956 Find Common Elements Between Two Arrays Solution
2960 Count Tested Devices After Test Operations Solution
2965 Find Missing and Repeated Values Solution
2970 Count the Number of Incremovable Subarrays I Solution
2974 Minimum Number Game Solution
2996 Smallest Missing Integer Greater Than Sequential Prefix Sum Solution
3000 Maximum Area of Longest Diagonal Rectangle Solution
3005 Count Elements With Maximum Frequency Solution
3010 Divide an Array Into Subarrays With Minimum Cost I Solution
3014 Minimum Number of Pushes to Type Word I Solution
3016 Minimum Number of Pushes to Type Word II Solution
3019 Number of Changing Keys Solution
problempush sh Solution

leetcodepractice's People

Contributors

qianzhangut avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.