Skip to content

sounishnath003/leetcode-practice-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode Solutions

# Title Solution Runtime
1 Two Sum Java 1 ms
2 Add Two Numbers C++ 36 ms
3 Longest Substring Without Repeating Characters C++ 60 ms
4 Median of Two Sorted Arrays Java 2 ms
5 Longest Palindromic Substring Java 387 ms
6 ZigZag Conversion Python3 64 ms
7 Reverse Integer C++ 0 ms
9 Palindrome Number Java 21 ms
11 Container With Most Water Java 3 ms
13 Roman to Integer C++ 4 ms
14 Longest Common Prefix Java 1 ms
15 3Sum Java 28 ms
17 Letter Combinations of a Phone Number C++ 0 ms
19 Remove Nth Node From End of List Java 0 ms
20 Valid Parentheses C++ 0 ms
21 Merge Two Sorted Lists Java 0 ms
22 Generate Parentheses Java 1 ms
23 Merge k Sorted Lists Java 4 ms
24 Swap Nodes in Pairs C++ 0 ms
25 Reverse Nodes in k-Group Java 1 ms
26 Remove Duplicates from Sorted Array Java 2 ms
28 Find the Index of the First Occurrence in a String Java 0 ms
31 Next Permutation C++ 4 ms
33 Search in Rotated Sorted Array C++ 4 ms
34 Find First and Last Position of Element in Sorted Array C++ 8 ms
36 Valid Sudoku Java 30 ms
38 Count and Say C# 88 ms
40 Combination Sum II Java 2 ms
45 Jump Game II Java 0 ms
46 Permutations Java 1 ms
49 Group Anagrams Java 17 ms
50 Pow(x, n) C++ 4 ms
51 N-Queens Java 3 ms
52 N-Queens II Java 0 ms
53 Maximum Subarray Java 1 ms
54 Spiral Matrix C++ 0 ms
55 Jump Game Java 1 ms
62 Unique Paths Java 23 ms
64 Minimum Path Sum C++ 20 ms
65 Valid Number Java 2 ms
66 Plus One C++ 0 ms
69 Sqrt(x) Python3 48 ms
70 Climbing Stairs C++ 0 ms
72 Edit Distance Java 5 ms
73 Set Matrix Zeroes Java 0 ms
74 Search a 2D Matrix Java 0 ms
75 Sort Colors Java 0 ms
76 Minimum Window Substring Java 12 ms
77 Combinations C++ 1376 ms
78 Subsets C++ 4 ms
79 Word Search Java 200 ms
80 Remove Duplicates from Sorted Array II C++ 8 ms
81 Search in Rotated Sorted Array II Java 0 ms
82 Remove Duplicates from Sorted List II Java 0 ms
83 Remove Duplicates from Sorted List Java 0 ms
84 Largest Rectangle in Histogram Java 52 ms
88 Merge Sorted Array C++ 4 ms
90 Subsets II Java 3 ms
91 Decode Ways Java 43 ms
94 Binary Tree Inorder Traversal Java 0 ms
98 Validate Binary Search Tree Java 0 ms
100 Same Tree Java 0 ms
101 Symmetric Tree C++ 4 ms
102 Binary Tree Level Order Traversal JavaScript 84 ms
103 Binary Tree Zigzag Level Order Traversal JavaScript 84 ms
104 Maximum Depth of Binary Tree C++ 4 ms
105 Construct Binary Tree from Preorder and Inorder Traversal Java 2 ms
106 Construct Binary Tree from Inorder and Postorder Traversal Java 4 ms
107 Binary Tree Level Order Traversal II JavaScript 88 ms
108 Convert Sorted Array to Binary Search Tree C++ 20 ms
109 Convert Sorted List to Binary Search Tree Java 0 ms
110 Balanced Binary Tree JavaScript 88 ms
114 Flatten Binary Tree to Linked List Python3 0 ms
118 Pascal's Triangle C++ 0 ms
121 Best Time to Buy and Sell Stock C++ 12 ms
122 Best Time to Buy and Sell Stock II Java 2 ms
123 Best Time to Buy and Sell Stock III Java 3 ms
124 Binary Tree Maximum Path Sum Java 1 ms
125 Valid Palindrome Python3 1228 ms
130 Surrounded Regions Java 5 ms
131 Palindrome Partitioning Java 8 ms
133 Clone Graph Java 25 ms
134 Gas Station Java 4 ms
136 Single Number C++ 32 ms
137 Single Number II C++ 16 ms
138 Copy List with Random Pointer Java 0 ms
140 Word Break II Java 9 ms
141 Linked List Cycle C++ 32 ms
142 Linked List Cycle II Java 0 ms
143 Reorder List Java 1 ms
144 Binary Tree Preorder Traversal Java 0 ms
145 Binary Tree Postorder Traversal Java 0 ms
146 LRU Cache Java 14 ms
148 Sort List Java 6 ms
150 Evaluate Reverse Polish Notation Java 7 ms
152 Maximum Product Subarray Java 1 ms
153 Find Minimum in Rotated Sorted Array Java 0 ms
155 Min Stack C++ 36 ms
160 Intersection of Two Linked Lists Java 1 ms
162 Find Peak Element Java 0 ms
164 Maximum Gap Java 2 ms
169 Majority Element C++ 56 ms
171 Excel Sheet Column Number C++ 4 ms
172 Factorial Trailing Zeroes Python3 32 ms
173 Binary Search Tree Iterator C++ 36 ms
179 Largest Number C++ 44 ms
188 Best Time to Buy and Sell Stock IV Java 10 ms
189 Rotate Array C++ 12 ms
190 Reverse Bits C++ 0 ms
191 Number of 1 Bits C++ 4 ms
198 House Robber Java 4 ms
200 Number of Islands Java 3 ms
202 Happy Number C++ 4 ms
204 Count Primes Java 33 ms
205 Isomorphic Strings Java 6 ms
206 Reverse Linked List Java 0 ms
207 Course Schedule Java 6 ms
208 Implement Trie (Prefix Tree) Java 38 ms
209 Minimum Size Subarray Sum Java 1 ms
210 Course Schedule II Java 8 ms
211 Design Add and Search Words Data Structure Java 786 ms
213 House Robber II Java 6 ms
215 Kth Largest Element in an Array Java 35 ms
217 Contains Duplicate C++ 108 ms
219 Contains Duplicate II Java 18 ms
224 Basic Calculator Python3 101 ms
226 Invert Binary Tree Java 0 ms
227 Basic Calculator II C++ 20 ms
229 Majority Element II Java 1 ms
230 Kth Smallest Element in a BST Java 0 ms
232 Implement Queue using Stacks Java 0 ms
234 Palindrome Linked List Java 15 ms
235 Lowest Common Ancestor of a Binary Search Tree Java 4 ms
237 Delete Node in a Linked List C++ 16 ms
238 Product of Array Except Self Java 11 ms
239 Sliding Window Maximum Java N/A
240 Search a 2D Matrix II Java 4 ms
242 Valid Anagram C++ 64 ms
268 Missing Number Java 0 ms
279 Perfect Squares Java 55 ms
283 Move Zeroes C++ 8 ms
290 Word Pattern Python3 36 ms
295 Find Median from Data Stream Java 107 ms
300 Longest Increasing Subsequence Java 65 ms
303 Range Sum Query - Immutable Java 9 ms
304 Range Sum Query 2D - Immutable Java 19 ms
309 Best Time to Buy and Sell Stock with Cooldown Java 0 ms
310 Minimum Height Trees Java 62 ms
315 Count of Smaller Numbers After Self Java 20 ms
318 Maximum Product of Word Lengths Java 251 ms
322 Coin Change Java 10 ms
324 Wiggle Sort II Java 2 ms
326 Power of Three C++ 92 ms
328 Odd Even Linked List Java 1 ms
332 Reconstruct Itinerary Java N/A
336 Palindrome Pairs Java 64 ms
344 Reverse String C++ 32 ms
345 Reverse Vowels of a String Java 18 ms
347 Top K Frequent Elements Java 20 ms
350 Intersection of Two Arrays II C++ 8 ms
352 Data Stream as Disjoint Intervals Java 273 ms
354 Russian Doll Envelopes Java 203 ms
380 Insert Delete GetRandom O(1) Java 130 ms
382 Linked List Random Node Java 18 ms
384 Shuffle an Array Java 75 ms
387 First Unique Character in a String C++ 148 ms
392 Is Subsequence Java 0 ms
395 Longest Substring with At Least K Repeating Characters C++ 0 ms
412 Fizz Buzz C++ 4 ms
415 Add Strings Java 4 ms
416 Partition Equal Subset Sum C++ 780 ms
419 Battleships in a Board C++ 12 ms
429 N-ary Tree Level Order Traversal Java 4 ms
433 Minimum Genetic Mutation Java 7 ms
435 Non-overlapping Intervals Java 86 ms
438 Find All Anagrams in a String Java 60 ms
450 Delete Node in a BST Java 0 ms
451 Sort Characters By Frequency Java 61 ms
452 Minimum Number of Arrows to Burst Balloons Java 124 ms
460 LFU Cache Java 65 ms
472 Concatenated Words Java 75 ms
473 Matchsticks to Square Java 970 ms
485 Max Consecutive Ones Java 2 ms
491 Non-decreasing Subsequences Java 13 ms
496 Next Greater Element I Java 3 ms
518 Coin Change 2 Java 3 ms
520 Detect Capital Java 1 ms
523 Continuous Subarray Sum Java 68 ms
525 Contiguous Array Java 19 ms
540 Single Element in a Sorted Array Java 0 ms
542 01 Matrix Java 13 ms
543 Diameter of Binary Tree Java 0 ms
547 Number of Provinces Java 3 ms
556 Next Greater Element III Java 9 ms
560 Subarray Sum Equals K Java 19 ms
561 Array Partition I Java 17 ms
563 Binary Tree Tilt Java 1 ms
572 Subtree of Another Tree Java 3 ms
576 Out of Boundary Paths Java 5 ms
583 Delete Operation for Two Strings Java 320 ms
605 Can Place Flowers Java 2 ms
609 Find Duplicate File in System Java 13 ms
611 Valid Triangle Number Java 32 ms
621 Task Scheduler C++ 344 ms
622 Design Circular Queue Java 10 ms
623 Add One Row to Tree Java 1 ms
628 Maximum Product of Three Numbers Java 4 ms
630 Course Schedule III Java N/A
637 Average of Levels in Binary Tree Java 4 ms
643 Maximum Average Subarray I Java 5 ms
645 Set Mismatch Java 33 ms
647 Palindromic Substrings Java 13 ms
665 Non-decreasing Array Java 0 ms
669 Trim a Binary Search Tree C++ 12 ms
670 Maximum Swap Java 8 ms
684 Redundant Connection Java 0 ms
692 Top K Frequent Words Java 18 ms
695 Max Area of Island Java 10 ms
700 Search in a Binary Search Tree JavaScript 100 ms
704 Binary Search Java 0 ms
709 To Lower Case Java 0 ms
718 Maximum Length of Repeated Subarray Java 51 ms
724 Find Pivot Index Java 1 ms
729 My Calendar I Java 20 ms
739 Daily Temperatures Java 241 ms
745 Prefix and Suffix Search Java 188 ms
746 Min Cost Climbing Stairs Java 3 ms
752 Open the Lock Java 28 ms
754 Reach a Number C++ 0 ms
766 Toeplitz Matrix Java 1 ms
783 Minimum Distance Between BST Nodes Java 0 ms
787 Cheapest Flights Within K Stops Java 4 ms
792 Number of Matching Subsequences Java 1867 ms
795 Number of Subarrays with Bounded Maximum Java 5 ms
797 All Paths From Source to Target Java 3 ms
815 Bus Routes Java 84 ms
816 Ambiguous Coordinates Java 11 ms
835 Image Overlap Java 99 ms
838 Push Dominoes Java 28 ms
839 Similar String Groups Java 167 ms
841 Keys and Rooms Java 3 ms
849 Maximize Distance to Closest Person Java 2 ms
863 All Nodes Distance K in Binary Tree Java 12 ms
865 Smallest Subtree with all the Deepest Nodes Java 0 ms
871 Minimum Number of Refueling Stops Java N/A
872 Leaf-Similar Trees Java 9 ms
875 Koko Eating Bananas Java 29 ms
876 Middle of the Linked List Java 0 ms
880 Decoded String at Index Java 7 ms
886 Possible Bipartition Java 91 ms
889 Construct Binary Tree from Preorder and Postorder Traversal Java 0 ms
890 Find and Replace Pattern Java 3 ms
897 Increasing Order Search Tree C++ 4 ms
904 Fruit Into Baskets C++ 256 ms
905 Sort Array By Parity Java 1 ms
906 Super Palindromes Java 809 ms
907 Sum of Subarray Minimums Java 78 ms
911 Online Election C++ 344 ms
912 Sort an Array Java 21 ms
915 Partition Array into Disjoint Intervals Java 1 ms
918 Maximum Sum Circular Subarray Java 4 ms
921 Minimum Add to Make Parentheses Valid Java 0 ms
925 Long Pressed Name Java 1 ms
929 Unique Email Addresses Java 13 ms
931 Minimum Falling Path Sum Java 12 ms
934 Shortest Bridge Java 6 ms
938 Range Sum of BST Java 0 ms
941 Valid Mountain Array C++ 104 ms
943 Find the Shortest Superstring Java 26 ms
946 Validate Stack Sequences Java 1 ms
952 Largest Component Size by Common Factor Java 405 ms
967 Numbers With Same Consecutive Differences Java 9 ms
968 Binary Tree Cameras Java 2 ms
974 Subarray Sums Divisible by K Java 4 ms
976 Largest Perimeter Triangle Java 15 ms
977 Squares of a Sorted Array C++ 52 ms
981 Time Based Key-Value Store Java 414 ms
987 Vertical Order Traversal of a Binary Tree Java 8 ms
990 Satisfiability of Equality Equations Java 14 ms
994 Rotting Oranges Java 19 ms
1008 Construct Binary Search Tree from Preorder Traversal Java 0 ms
1015 Smallest Integer Divisible by K C++ 0 ms
1020 Number of Enclaves Java 12 ms
1026 Maximum Difference Between Node and Ancestor Java 1 ms
1048 Longest String Chain Java 116 ms
1051 Height Checker Java 1 ms
1061 Lexicographically Smallest Equivalent String Java 25 ms
1094 Car Pooling Java 16 ms
1110 Delete Nodes And Return Forest Java 1 ms
1122 Relative Sort Array Java 3 ms
1123 Lowest Common Ancestor of Deepest Leaves C++ 24 ms
1137 N-th Tribonacci Number Java 0 ms
1143 Longest Common Subsequence Java 14 ms
1155 Number of Dice Rolls With Target Sum Java 86 ms
1162 As Far from Land as Possible Java 11 ms
1192 Critical Connections in a Network Java 134 ms
1235 Maximum Profit in Job Scheduling Java 98 ms
1239 Maximum Length of a Concatenated String with Unique Characters Java 55 ms
1268 Search Suggestions System Java 8 ms
1293 Shortest Path in a Grid with Obstacles Elimination Java 37 ms
1302 Deepest Leaves Sum Java 2 ms
1306 Jump Game III Java 8 ms
1329 Sort the Matrix Diagonally C++ 8 ms
1339 Maximum Product of Splitted Binary Tree Java 10 ms
1354 Construct Target Array With Multiple Sums Java N/A
1383 Maximum Performance of a Team Java 49 ms
1423 Maximum Points You Can Obtain from Cards Java 1 ms
1443 Minimum Time to Collect All Apples in a Tree Java 43 ms
1448 Count Good Nodes in Binary Tree Java 4 ms
1457 Pseudo-Palindromic Paths in a Binary Tree C++ 204 ms
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts Java 22 ms
1472 Design Browser History Java 58 ms
1480 Running Sum of 1d Array Java 0 ms
1498 Number of Subsequences That Satisfy the Given Sum Condition Java 41 ms
1584 Min Cost to Connect All Points Java 440 ms
1626 Best Team With No Conflicts Java 252 ms
1639 Number of Ways to Form a Target String Given a Dictionary Java 107 ms
1641 Count Sorted Vowel Strings C++ 720 ms
1646 Get Maximum in Generated Array C++ 0 ms
1657 Determine if Two Strings Are Close Java 81 ms
1658 Minimum Operations to Reduce X to Zero C++ 148 ms
1662 Check If Two String Arrays are Equivalent Java 1 ms
1679 Max Number of K-Sum Pairs C++ 156 ms
1680 Concatenation of Consecutive Binary Numbers Python3 3696 ms
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers Java 5 ms
1695 Maximum Erasure Value Java 53 ms
1696 Jump Game VI Java 85 ms
1704 Determine if String Halves Are Alike Java 7 ms
1706 Where Will the Ball Fall Java 1 ms
1710 Maximum Units on a Truck Java 122 ms
1832 Check if the Sentence Is Pangram Java 10 ms
1833 Maximum Ice Cream Bars Java 57 ms
1834 Single-Threaded CPU Java 115 ms
1901 Find a Peak Element II Java 1 ms
1910 Remove All Occurrences of a Substring Python 24 ms
1921 Eliminate Maximum Number of Monsters Java 26 ms
1926 Nearest Exit from Entrance in Maze Java 8 ms
1962 Remove Stones to Minimize the Total Java 500 ms
1971 Find if Path Exists in Graph Java 27 ms
1996 The Number of Weak Characters in the Game Java 216 ms
2007 Find Original Array From Doubled Array Java 231 ms
2095 Delete the Middle Node of a Linked List Java 6 ms
2136 Earliest Possible Day of Full Bloom Java 187 ms
2225 Find Players With Zero or One Losses Java 645 ms
2244 Minimum Rounds to Complete All Tasks Java 122 ms
2299 Strong Password Checker II Java 3 ms
2300 Successful Pairs of Spells and Potions Java 87 ms
2301 Match Substring After Replacement Java 229 ms
2341 Maximum Number of Pairs in Array Java 2 ms
2389 Longest Subsequence With Limited Sum Java 11 ms
2466 Count Ways To Build Good Strings Java 50 ms
NaN Number of Ways to Stay in the Same Place After Some Steps Java 507 ms
NaN Number of Ways to Stay in the Same Place After Some Steps Java 507 ms
NaN Design Twitter Java 10 ms
NaN Number of Great Partitions Java 717 ms
NaN Delete and Earn Java 8 ms
NaN Swap Nodes in Pairs Java 0 ms
NaN Maximum Frequency Stack Java 34 ms
NaN Find Largest Value in Each Tree Row Java 9 ms
2616 Minimize the Maximum Difference of Pairs Java 18 ms

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published