Skip to content

bossm0n5t3r/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

  • LeetCode solutions in Kotlin

Solved Problems

# Title Solution
1 Two Sum Solution
2 Add Two Numbers Solution
3 Longest Substring Without Repeating Characters Solution
4 Median of Two Sorted Arrays Solution
5 Longest Palindromic Substring Solution
6 Zigzag Conversion Solution
7 Reverse Integer Solution
8 String to Integer (atoi) Solution
11 Container With Most Water Solution
12 Integer to Roman Solution
13 Roman to Integer Solution
14 Longest Common Prefix Solution
15 3Sum Solution
16 3Sum Closest Solution
17 Letter Combinations of a Phone Number Solution
18 4Sum Solution
19 Remove Nth Node From End of List Solution
20 Valid Parentheses Solution
21 Merge Two Sorted Lists Solution
22 Generate Parentheses Solution
23 Merge k Sorted Lists Solution
24 Swap Nodes in Pairs Solution
25 Reverse Nodes in k-Group Solution
26 Remove Duplicates from Sorted Array Solution
27 Remove Element Solution
28 Implement strStr() Solution
29 Divide Two Integers Solution
31 Next Permutation Solution
33 Search in Rotated Sorted Array Solution
34 Find First and Last Position of Element in Sorted Array Solution
35 Search Insert Position Solution
36 Valid Sudoku Solution
37 Sudoku Solver Solution
38 Count and Say Solution
39 Combination Sum Solution
40 Combination Sum II Solution
42 Trapping Rain Water Solution
43 Multiply Strings Solution
45 Jump Game II Solution
46 Permutations Solution
47 Permutations II Solution
48 Rotate Image Solution
49 Group Anagrams Solution
50 Pow(x, n) Solution
51 N-Queens Solution
52 N-Queens II Solution
53 Maximum Subarray Solution
55 Jump Game Solution
58 Length of Last Word Solution
59 Spiral Matrix II Solution
62 Unique Paths Solution
63 Unique Paths II Solution
66 Plus One Solution
68 Text Justification Solution
69 Sqrt(x) Solution
70 Climbing Stairs Solution
71 Simplify Path Solution
72 Edit Distance Solution
73 Set Matrix Zeroes Solution
75 Sort Colors Solution
76 Minimum Window Substring Solution
78 Subsets Solution
79 Word Search Solution
80 Remove Duplicates from Sorted Array II Solution
88 Merge Sorted Array 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
108 Convert Sorted Array to Binary Search Tree Solution
111 Minimum Depth of Binary Tree Solution
118 Pascal's Triangle Solution
120 Triangle Solution
121 Best Time to Buy and Sell Stock Solution
122 Best Time to Buy and Sell Stock II Solution
125 Valid Palindrome Solution
131 Palindrome Partitioning Solution
133 Clone Graph Solution
134 Gas Station Solution
135 Candy Solution
136 Single Number Solution
139 Word Break Solution
141 Linked List Cycle Solution
143 Reorder List Solution
149 Max Points on a Line Solution
150 Evaluate Reverse Polish Notation Solution
151 Reverse Words in a String Solution
155 Min Stack Solution
160 Intersection of Two Linked Lists Solution
162 Find Peak Element Solution
165 Compare Version Numbers Solution
167 Two Sum II - Input Array Is Sorted Solution
169 Majority Element Solution
171 Excel Sheet Column Number Solution
172 Factorial Trailing Zeroes Solution
179 Largest Number Solution
189 Rotate Array Solution
190 Reverse Bits Solution
191 Number of 1 Bits Solution
198 House Robber Solution
199 Binary Tree Right Side View Solution
200 Number of Islands Solution
201 Bitwise AND of Numbers Range Solution
202 Happy Number Solution
204 Count Primes Solution
206 Reverse Linked List Solution
208 Implement Trie (Prefix Tree) Solution
209 Minimum Size Subarray Sum Solution
215 Kth Largest Element in an Array Solution
216 Combination Sum III Solution
217 Contains Duplicate Solution
219 Contains Duplicate II Solution
225 Implement Stack using Queues Solution
230 Kth Smallest Element in a BST Solution
231 Power of Two Solution
232 Implement Queue using Stacks Solution
234 Palindrome Linked List Solution
236 Lowest Common Ancestor of a Binary Tree Solution
237 Delete Node in a Linked List Solution
238 Product of Array Except Self Solution
240 Search a 2D Matrix II Solution
241 Different Ways to Add Parentheses Solution
242 Valid Anagram Solution
260 Single Number III Solution
268 Missing Number Solution
273 Integer to English Words Solution
274 H-Index Solution
279 Perfect Squares Solution
283 Move Zeroes Solution
287 Find the Duplicate Number Solution
289 Game of Life Solution
304 Range Sum Query 2D - Immutable Solution
310 Minimum Height Trees Solution
318 Maximum Product of Word Lengths Solution
322 Coin Change Solution
326 Power of Three Solution
328 Odd Even Linked List Solution
329 Longest Increasing Path in a Matrix Solution
334 Increasing Triplet Subsequence Solution
338 Counting Bits 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
350 Intersection of Two Arrays II Solution
368 Largest Divisible Subset Solution
371 Sum of Two Integers Solution
374 Guess Number Higher or Lower Solution
377 Combination Sum IV Solution
378 Kth Smallest Element in a Sorted Matrix Solution
380 Insert Delete GetRandom O(1) Solution
381 Insert Delete GetRandom O(1) - Duplicates allowed Solution
386 Lexicographical Numbers Solution
387 First Unique Character in a String Solution
392 Is Subsequence Solution
394 Decode String Solution
399 Evaluate Division Solution
409 Longest Palindrome Solution
412 Fizz Buzz Solution
416 Partition Equal Subset Sum Solution
435 Non-overlapping Intervals Solution
437 Path Sum III Solution
440 K-th Smallest in Lexicographical Order Solution
442 Find All Duplicates in an Array Solution
443 String Compression Solution
450 Delete Node in a BST Solution
451 Sort Characters By Frequency Solution
452 Minimum Number of Arrows to Burst Balloons Solution
456 132 Pattern Solution
463 Island Perimeter Solution
474 Ones and Zeroes Solution
476 Number Complement Solution
495 Teemo Attacking Solution
506 Relative Ranks Solution
513 Find Bottom Left Tree Value Solution
514 Freedom Trail Solution
523 Continuous Subarray Sum Solution
535 Encode and Decode TinyURL Solution
539 Minimum Time Difference Solution
543 Diameter of Binary Tree Solution
547 Number of Provinces Solution
581 Shortest Unsorted Continuous Subarray Solution
583 Delete Operation for Two Strings Solution
590 N-ary Tree Postorder Traversal Solution
592 Fraction Addition and Subtraction Solution
605 Can Place Flowers Solution
633 Sum of Square Numbers Solution
641 Design Circular Deque Solution
643 Maximum Average Subarray I Solution
645 Set Mismatch Solution
647 Palindromic Substrings Solution
648 Replace Words Solution
649 Dota2 Senate Solution
664 Strange Printer Solution
667 Beautiful Arrangement II Solution
678 Valid Parenthesis String Solution
682 Baseball Game Solution
700 Search in a Binary Search Tree Solution
706 Design HashMap Solution
713 Subarray Product Less Than K Solution
714 Best Time to Buy and Sell Stock with Transaction Fee Solution
719 Find K-th Smallest Pair Distance Solution
724 Find Pivot Index Solution
725 Split Linked List in Parts Solution
729 My Calendar I Solution
735 Asteroid Collision Solution
739 Daily Temperatures Solution
743 Network Delay Time Solution
746 Min Cost Climbing Stairs Solution
752 Open the Lock Solution
773 Sliding Puzzle Solution
777 Swap Adjacent in LR String Solution
781 Rabbits in Forest Solution
786 K-th Smallest Prime Fraction Solution
790 Domino and Tromino Tiling Solution
791 Custom Sort String Solution
796 Rotate String Solution
802 Find Eventual Safe States Solution
826 Most Profit Assigning Work Solution
827 Making A Large Island Solution
840 Magic Squares In Grid Solution
841 Keys and Rooms Solution
844 Backspace String Compare Solution
846 Hand of Straights Solution
858 Mirror Reflection Solution
862 Shortest Subarray with Sum at Least K Solution
865 Smallest Subtree with all the Deepest Nodes Solution
872 Leaf-Similar Trees Solution
874 Walking Robot Simulation Solution
875 Koko Eating Bananas Solution
876 Middle of the Linked List Solution
881 Boats to Save People Solution
884 Uncommon Words from Two Sentences Solution
901 Online Stock Span Solution
905 Sort Array By Parity Solution
907 Sum of Subarray Minimums 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
933 Number of Recent Calls Solution
945 Minimum Increment to Make Array Unique Solution
951 Flip Equivalent Binary Trees Solution
974 Subarray Sums Divisible by K Solution
977 Squares of a Sorted Array Solution
979 Distribute Coins in Binary Tree Solution
980 Unique Paths III Solution
983 Minimum Cost For Tickets Solution
994 Rotting Oranges Solution
995 Minimum Number of K Consecutive Bit Flips Solution
997 Find the Town Judge Solution
1002 Find Common Characters Solution
1004 Max Consecutive Ones III Solution
1038 Binary Search Tree to Greater Sum Tree Solution
1043 Partition Array for Maximum Sum Solution
1047 Remove All Adjacent Duplicates In String Solution
1048 Longest String Chain Solution
1051 Height Checker Solution
1052 Grumpy Bookstore Owner Solution
1071 Greatest Common Divisor of Strings Solution
1079 Letter Tile Possibilities Solution
1091 Shortest Path in Binary Matrix Solution
1105 Filling Bookcase Shelves Solution
1106 Parsing A Boolean Expression Solution
1122 Relative Sort Array Solution
1123 Lowest Common Ancestor of Deepest Leaves Solution
1137 N-th Tribonacci Number Solution
1143 Longest Common Subsequence Solution
1161 Maximum Level Sum of a Binary Tree Solution
1171 Remove Zero Sum Consecutive Nodes from Linked List Solution
1202 Smallest String With Swaps Solution
1207 Unique Number of Occurrences Solution
1208 Get Equal Substrings Within Budget Solution
1209 Remove All Adjacent Duplicates in String II Solution
1219 Path with Maximum Gold Solution
1248 Count Number of Nice Subarrays Solution
1249 Minimum Remove to Make Valid Parentheses Solution
1260 Shift 2D Grid Solution
1267 Count Servers that Communicate Solution
1268 Search Suggestions System Solution
1277 Count Square Submatrices with All Ones Solution
1289 Minimum Falling Path Sum II Solution
1291 Sequential Digits Solution
1293 Shortest Path in a Grid with Obstacles Elimination Solution
1295 Find Numbers with Even Number of Digits Solution
1302 Deepest Leaves Sum Solution
1310 XOR Queries of a Subarray Solution
1318 Minimum Flips to Make a OR b Equal to c Solution
1331 Rank Transform of an Array Solution
1346 Check If N and Its Double Exist Solution
1352 Product of the Last K Numbers Solution
1356 Sort Integers by The Number of 1 Bits Solution
1358 Number of Substrings Containing All Three Characters Solution
1367 Linked List in Binary Tree Solution
1372 Longest ZigZag Path in a Binary Tree Solution
1380 Lucky Numbers in a Matrix Solution
1381 Design a Stack With Increment Operation Solution
1382 Balance a Binary Search Tree Solution
1395 Count Number of Teams Solution
1399 Count Largest Group Solution
1400 Construct K Palindrome Strings Solution
1404 Number of Steps to Reduce a Number in Binary Representation to One Solution
1405 Longest Happy String Solution
1408 String Matching in an Array Solution
1415 The k-th Lexicographical String of All Happy Strings of Length n Solution
1422 Maximum Score After Splitting a String Solution
1431 Kids With the Greatest Number of Candies Solution
1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit Solution
1448 Count Good Nodes in Binary Tree Solution
1450 Number of Students Doing Homework at a Given Time Solution
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence Solution
1456 Maximum Number of Vowels in a Substring of Given Length Solution
1463 Cherry Pickup II Solution
1466 Reorder Routes to Make All Paths Lead to the City Zero Solution
1480 Running Sum of 1d Array Solution
1481 Least Number of Unique Integers after K Removals Solution
1482 Minimum Number of Days to Make m Bouquets Solution
1493 Longest Subarray of 1's After Deleting One Element Solution
1497 Check If Array Pairs Are Divisible by k Solution
1509 Minimum Difference Between Largest and Smallest Value in Three Moves Solution
1514 Path with Maximum Probability Solution
1518 Water Bottles Solution
1524 Number of Sub-arrays With Odd Sum Solution
1530 Number of Good Leaf Nodes Pairs Solution
1534 Count Good Triplets Solution
1545 Find Kth Bit in Nth Binary String Solution
1550 Three Consecutive Odds Solution
1574 Shortest Subarray to be Removed to Make Array Sorted Solution
1590 Make Sum Divisible by P Solution
1593 Split a String Into the Max Number of Unique Substrings Solution
1598 Crawler Log Folder Solution
1608 Special Array With X Elements Greater Than or Equal X Solution
1626 Best Team With No Conflicts Solution
1636 Sort Array by Increasing Frequency Solution
1642 Furthest Building You Can Reach Solution
1652 Defuse the Bomb Solution
1653 Minimum Deletions to Make String Balanced Solution
1657 Determine if Two Strings Are Close Solution
1658 Minimum Operations to Reduce X to Zero Solution
1669 Merge In Between Linked Lists Solution
1679 Max Number of K-Sum Pairs Solution
1684 Count the Number of Consistent Strings Solution
1695 Maximum Erasure Value Solution
1700 Number of Students Unable to Eat Lunch Solution
1701 Average Waiting Time Solution
1718 Construct the Lexicographically Largest Valid Sequence Solution
1726 Tuple with Same Product Solution
1732 Find the Highest Altitude Solution
1750 Minimum Length of String After Deleting Similar Ends Solution
1752 Check if Array Is Sorted and Rotated Solution
1758 Minimum Changes To Make Alternating Binary String Solution
1765 Map of Highest Peak Solution
1768 Merge Strings Alternately Solution
1769 Minimum Number of Operations to Move All Balls to Each Box Solution
1780 Check if Number is a Sum of Powers of Three Solution
1790 Check if One String Swap Can Make Strings Equal Solution
1791 Find Center of Star Graph Solution
1800 Maximum Ascending Subarray Sum Solution
1823 Find the Winner of the Circular Game Solution
1829 Maximum XOR for Each Query Solution
1863 Sum of All Subset XOR Totals Solution
1882 Process Tasks Using Servers Solution
1894 Find the Student that Will Replace the Chalk Solution
1905 Count Sub Islands Solution
1906 Minimum Absolute Difference Queries Solution
1910 Remove All Occurrences of a Substring Solution
1915 Number of Wonderful Substrings Solution
1922 Count Good Numbers Solution
1926 Nearest Exit from Entrance in Maze Solution
1930 Unique Length-3 Palindromic Subsequences Solution
1945 Sum of Digits of String After Convert Solution
1957 Delete Characters to Make Fancy String Solution
1963 Minimum Number of Swaps to Make the String Balanced Solution
1971 Find if Path Exists in Graph Solution
1980 Find Unique Binary String Solution
1992 Find All Groups of Farmland Solution
2000 Reverse Prefix of Word Solution
2016 Maximum Difference Between Increasing Elements Solution
2017 Grid Game Solution
2022 Convert 1D Array Into 2D Array Solution
2024 Maximize the Confusion of an Exam Solution
2028 Find Missing Observations Solution
2037 Minimum Number of Moves to Seat Everyone Solution
2044 Count Number of Maximum Bitwise-OR Subsets Solution
2053 Kth Distinct String in an Array Solution
2070 Most Beautiful Item for Each Query Solution
2073 Time Needed to Buy Tickets Solution
2090 K Radius Subarray Averages Solution
2095 Delete the Middle Node of a Linked List Solution
2108 Find First Palindromic String in the Array Solution
2109 Adding Spaces to a String Solution
2115 Find All Possible Recipes from Given Supplies Solution
2116 Check if a Parentheses String Can Be Valid Solution
2130 Maximum Twin Sum of a Linked List Solution
2131 Longest Palindrome by Concatenating Two Letter Words Solution
2133 Check if Every Row and Column Contains All Numbers Solution
2140 Solving Questions With Brainpower Solution
2145 Count the Hidden Sequences Solution
2149 Rearrange Array Elements by Sign Solution
2161 Partition Array According to Given Pivot Solution
2176 Count Equal and Divisible Pairs in an Array Solution
2179 Count Good Triplets in an Array Solution
2181 Merge Nodes in Between Zeros Solution
2185 Counting Words With a Given Prefix Solution
2186 Minimum Number of Steps to Make Two Strings Anagram II Solution
2192 All Ancestors of a Node in a Directed Acyclic Graph Solution
2206 Divide Array Into Equal Pairs Solution
2215 Find the Difference of Two Arrays Solution
2220 Minimum Bit Flips to Convert Number Solution
2257 Count Unguarded Cells in the Grid Solution
2270 Number of Ways to Split Array Solution
2275 Largest Combination With Bitwise AND Greater Than Zero Solution
2285 Maximum Total Importance of Roads Solution
2290 Minimum Obstacle Removal to Reach Corner Solution
2300 Successful Pairs of Spells and Potions Solution
2309 Greatest English Letter in Upper and Lower Case Solution
2326 Spiral Matrix IV Solution
2336 Smallest Number in Infinite Set Solution
2337 Move Pieces to Obtain a String Solution
2338 Count the Number of Ideal Arrays Solution
2342 Max Sum of a Pair With Equal Sum of Digits Solution
2349 Design a Number Container System Solution
2352 Equal Row and Column Pairs Solution
2364 Count Number of Bad Pairs Solution
2373 Largest Local Values in a Matrix Solution
2375 Construct Smallest Number From DI String Solution
2379 Minimum Recolors to Get K Consecutive Black Blocks Solution
2381 Shifting Letters II Solution
2390 Removing Stars From a String Solution
2401 Longest Nice Subarray Solution
2402 Meeting Rooms III Solution
2406 Divide Intervals Into Minimum Number of Groups Solution
2416 Sum of Prefix Scores of Strings Solution
2418 Sort the People Solution
2419 Longest Subarray With Maximum Bitwise AND Solution
2425 Bitwise XOR of All Pairings Solution
2427 Number of Common Factors Solution
2429 Minimize XOR Solution
2441 Largest Positive Integer That Exists With Its Negative Solution
2451 Odd String Difference Solution
2460 Apply Operations to an Array Solution
2461 Maximum Sum of Distinct Subarrays With Length K Solution
2462 Total Cost to Hire K Workers 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
2491 Divide Players Into Teams of Equal Skill Solution
2501 Longest Square Streak in an Array Solution
2503 Maximum Number of Points From Grid Queries Solution
2523 Closest Prime Numbers in Range Solution
2527 Find Xor-Beauty of Array Solution
2529 Maximum Count of Positive Integer and Negative Integer Solution
2530 Maximal Score After Applying K Operations Solution
2537 Count the Number of Good Subarrays Solution
2540 Minimum Common Value Solution
2542 Maximum Subsequence Score 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
2563 Count the Number of Fair Pairs Solution
2570 Merge Two 2D Arrays by Summing Values Solution
2577 Minimum Time to Visit a Cell In a Grid Solution
2579 Count Total Number of Colored Cells Solution
2582 Pass the Pillow Solution
2583 Kth Largest Sum in a Binary Tree Solution
2587 Rearrange Array to Maximize Prefix Score Solution
2597 The Number of Beautiful Subsets Solution
2601 Prime Subtraction Operation Solution
2657 Find the Prefix Common Array of Two Arrays Solution
2658 Maximum Number of Fish in a Grid Solution
2661 First Completely Painted Row or Column Solution
2678 Number of Senior Citizens Solution
2684 Maximum Number of Moves in a Grid Solution
2707 Extra Characters in a String Solution
2788 Split Strings by Separator Solution
2799 Count Complete Subarrays in an Array Solution
2807 Insert Greatest Common Divisors in Linked List Solution
2816 Double a Number Represented as a Linked List Solution
2825 Make String a Subsequence Using Cyclic Increments Solution
2843 Count Symmetric Integers Solution
2845 Count of Interesting Subarrays Solution
2864 Maximum Odd Binary Number Solution
2873 Maximum Value of an Ordered Triplet I Solution
2874 Maximum Value of an Ordered Triplet II Solution
2894 Divisible and Non-divisible Sums Difference Solution
2914 Minimum Number of Changes to Make Binary String Beautiful Solution
2924 Find Champion II Solution
2929 Distribute Candies Among Children II Solution
2938 Separate Black and White Balls Solution
2942 Find Words Containing Character Solution
2965 Find Missing and Repeated Values Solution
2971 Find Polygon With the Largest Perimeter Solution
2996 Smallest Missing Integer Greater Than Sequential Prefix Sum Solution
2997 Minimum Number of Operations to Make Array XOR Equal to K Solution
3005 Count Elements With Maximum Frequency Solution
3011 Find if Array Can Be Sorted Solution
3042 Count Prefix and Suffix Pairs I Solution
3066 Minimum Operations to Exceed Threshold Value II Solution
3069 Distribute Elements Into Two Arrays I Solution
3071 Minimum Operations to Write the Letter Y on a Grid Solution
3075 Maximize Happiness of Selected Children Solution
3083 Existence of a Substring in a String and Its Reverse Solution
3105 Longest Strictly Increasing or Strictly Decreasing Subarray Solution
3110 Score of a String Solution
3151 Special Array I Solution
3160 Find the Number of Distinct Colors Among the Balls Solution
3163 String Compression III Solution
3169 Count Days Without Meetings Solution
3170 Lexicographically Minimum String After Removing Stars Solution
3174 Clear Digits Solution
3191 Minimum Operations to Make Binary Array Elements Equal to One I Solution
3217 Delete Nodes From Linked List Present in Array Solution
3223 Minimum Length of String After Operations Solution
3243 Shortest Distance After Road Addition Queries I Solution
3306 Count of Substrings Containing Every Vowel and K Consonants II Solution
3334 Find the Maximum Factor Score of Array Solution
3335 Total Characters in String After Transformations I Solution
3337 Total Characters in String After Transformations II Solution
3340 Check Balanced String Solution
3341 Find Minimum Time to Reach Last Room I Solution
3375 Minimum Operations to Make Array Values Equal to K Solution
3394 Check if Grid can be Cut into Sections Solution
3396 Minimum Number of Operations to Make Elements in Array Distinct Solution
3423 Maximum Difference Between Adjacent Elements in a Circular Array Solution
3442 Maximum Difference Between Even and Odd Frequency I Solution
3507 Minimum Pair Removal to Sort Array I Solution
3508 Implement Router Solution

About

LeetCode Problem Solutions using Kotlin

Topics

Resources

Stars

Watchers

Forks

Languages