Skip to content

This is a repository with solutions to LeetCode problems, mainly in Python and SQL. It contains an auto-generated table of all solutions with links to the solution, problem, and BigO time and memory analysis.

License

Kyrylo-Ktl/LeetCode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The repository contains the best versions of my solutions to LeetCode problems

Author

Complexity chart

complexity_chart

Number of operations for complexity

$f(n)$ $n = 10$ $n = 10^{2}$ $n = 10^{3}$ $n = 10^{4}$ $n = 10^{5}$ $n = 10^{6}$
$1$ $1$ $1$ $1$ $1$ $1$ $1$
$\log n$ $\approx 3.32$ $\approx 6.64$ $\approx 9.97$ $\approx 1.33 * 10$ $\approx 1.66 * 10$ $\approx 1.99 * 10$
$n$ $10$ $10^{2}$ $10^{3}$ $10^{4}$ $10^{5}$ $10^{6}$
$n * \log n$ $\approx 3.32 * 10$ $\approx 6.64 * 10^{2}$ $\approx 9.97 * 10^{3}$ $\approx 1.33 * 10^{5}$ $\approx 1.66 * 10^{6}$ $\approx 1.99 * 10^{7}$
$n^{2}$ $10^{2}$ $10^{4}$ $10^{6}$ $10^{8}$ $10^{10}$ $10^{12}$
$2^{n}$ $\approx 10^{3}$ $\approx 10^{30}$ $\approx 10^{301}$ $\approx 10^{3010}$ $\approx 10^{30102}$ $\approx 10^{301030}$
$n!$ $\approx 10^{7}$ $\approx 10^{156}$ $\approx 10^{2568}$ $\approx 10^{35660}$ $\approx 10^{456574}$ $\approx 10^{5565709}$

Complexity notations

Notation Name Sign Meaning
$o$ Little O $<$ Less than
$O$ Big O $\leq$ Less than or equal to
$\Theta$ Theta $=$ Equal to
$\Omega$ Big Omega $\geq$ Greater than or equal to
$\omega$ Little Omega $>$ Greater than

Solutions

Title Solutions Time Memory Notes Beats Time Beats Memory
1 Two Sum Python, Java $O(n)$ $O(n)$ - 99.78% 88.62%
2 Add Two Numbers Python, Java $O(n+m)$ $O(1)$ - 99.36% 95.33%
3 Longest Substring Without Repeating Characters Python, Java $O(n)$ $O(1)$ - 100.00% 91.50%
6 Zigzag Conversion Python $O(n)$ $O(n)$ - - -
8 String to Integer (atoi) Python $O(n)$ $O(n)$ RegEx 94.55% 100.00%
9 Palindrome Number Python, Java $O(\log_{10} n)$ $O(1)$ - 95.52% 100.00%
10 Regular Expression Matching Python $O(n*m)$ $O(n*m)$ DP - -
11 Container With Most Water Python, Java $O(n)$ $O(1)$ Two Pointers 98.13% 91.81%
12 Integer to Roman Python $O(1)$ $O(1)$ - - -
13 Roman to Integer Python $O(1)$ $O(1)$ - - -
14 Longest Common Prefix Python $O(n)$ $O(1)$ - - -
15 3Sum Python $O(n^{2})$ $O(1)$ Two Pointers - -
19 Remove Nth Node From End of List Python, Java $O(n)$ $O(1)$ - - -
20 Valid Parentheses Python, Java $O(n)$ $O(n)$ Stack 99.78% 94.20%
22 Generate Parentheses Python, Java $O(2^{n})$ $O(n)$ Backtracking - -
26 Remove Duplicates from Sorted Array Python, Java $O(n)$ $O(1)$ - 100.00% 85.81%
27 Remove Element Python, Java $O(n)$ $O(1)$ - 100.00% 85.12%
30 Substring with Concatenation of All Words Python $O(n*k)$ $O(m*k)$ - - -
36 Valid Sudoku Python, Java $O(n^{2})$ $O(n^{2})$ - 100.00% 97.10%
38 Count and Say Python $O(2^{n})$ $O(2^{n})$ - - -
42 Trapping Rain Water Python $O(n)$ $O(n)$ - - -
48 Rotate Image Python $O(n^{2})$ $O(1)$ - 99.29% 98.14%
49 Group Anagrams Python $O(n * m * \log_{2} m)$ $O(n * m)$ - - -
50 Pow(x, n) Python $O(\log_{2} n)$ $O(\log_{2} n)$ BinPow - -
53 Maximum Subarray Python, Java $O(n)$ $O(1)$ Kadane's 100.00% 93.17%
54 Spiral Matrix Python ? ? - - -
55 Jump Game Python $O(n)$ $O(1)$ - - -
61 Rotate List Python $O(n)$ $O(1)$ - - -
62 Unique Paths Python, Java $O(min(n,m))$ $O(1)$ DP / Math - -
68 Text Justification Python $O(n)$ $O(n)$ - - -
70 Climbing Stairs Python $O(n)$ $O(n)$ DP - -
71 Simplify Path Python $O(n)$ $O(n)$ - - -
72 Edit Distance Python, Java $O(n*m)$ $O(n*m)$ DP 92.85% 91.32%
73 Set Matrix Zeroes Python $O(n * m)$ $O(n + m)$ - 97.19% 53.65%
74 Search a 2D Matrix Python, Java $O(\log_{2} (n*m))$ $O(1)$ Binary Search - -
78 Subsets Python $O(2^{n})$ $O(n)$ - - -
79 Word Search Python $O(n * m * k)$ $O(k)$ DFS 99.72% 93.26%
80 Remove Duplicates from Sorted Array II Python $O(n)$ $O(1)$ - - -
82 Remove Duplicates from Sorted List II Python $O(n)$ $O(1)$ - - -
86 Partition List Python $O(n)$ $O(1)$ - - -
88 Merge Sorted Array Python, Java $O(n + m)$ $O(1)$ - 100.00% 83.33%
89 Gray Code Python, Java $O(2^{n})$ $O(1)$ Math 96.07% 97.95%
91 Decode Ways Python $O(n)$ $O(n)$ DP - -
94 Binary Tree Inorder Traversal Python $O(n)$ $O(n)$ - - -
95 Unique Binary Search Trees II Python $O(n^{2})$ $O(\log_{2} n)$ DP - -
96 Unique Binary Search Trees Python $O(n)$ $O(1)$ DP, Math - -
98 Validate Binary Search Tree Python $O(n)$ $O(n)$ DFS - -
100 Same Tree Python $O(n)$ $O(H)$ - - -
101 Symmetric Tree Python $O(n)$ $O(n)$ DFS, BFS - -
104 Maximum Depth of Binary Tree Python $O(n)$ $O(n)$ DFS - -
108 Convert Sorted Array to Binary Search Tree Python $O(n)$ $O(\log_{2} n)$ - - -
109 Convert Sorted List to Binary Search Tree Python $O(n*\log_{2} n)$ $O(\log_{2} n)$ DFS - -
111 Minimum Depth of Binary Tree Python, Java $O(n)$ $O(n)$ - 99.77% 94.85%
112 Path Sum Python $O(n)$ $O(n)$ DFS - -
113 Path Sum II Python - - - - -
114 Flatten Binary Tree to Linked List Python $O(n)$ $O(1)$ - - -
124 Binary Tree Maximum Path Sum Python $O(n)$ $O(n)$ - - -
125 Valid Palindrome Python, Java $O(n)$ $O(1)$ - 99.31% 92.66%
126 Word Ladder II Python - - - - -
127 Word Ladder Python - - - - -
129 Sum Root to Leaf Numbers Python $O(n)$ $O(h)$ DFS 97.50% 95.89%
136 Single Number Python, Java $O(n)$ $O(1)$ - 100.00% 93.84%
141 Linked List Cycle Python, Java $O(n)$ $O(1)$ - 100.00% 95.88%
150 Evaluate Reverse Polish Notation Python $O(n)$ $O(n)$ - - -
151 Reverse Words in a String Python $O(n)$ $O(n)$ - - -
155 Min Stack Python $O(1)$ $O(n)$ - - -
165 Compare Version Numbers Python $O(max(n,m))$ $O(n+m)$ - - -
168 Excel Sheet Column Title Python $O(\log_{26} n)$ $O(1)$ - - -
172 Factorial Trailing Zeroes Python $O(\log_{5} n)$ $O(\log_{5} n)$ Math - -
175 Combine Two Tables SQL SQL SQL - - -
176 Second Highest Salary SQL SQL SQL - - -
177 Nth Highest Salary SQL SQL SQL - - -
178 Rank Scores SQL SQL SQL - - -
180 Consecutive Numbers SQL SQL SQL - - -
181 Employees Earning More Than Their Managers SQL SQL SQL - - -
182 Duplicate Emails SQL SQL SQL - - -
183 Customers Who Never Order SQL SQL SQL - - -
184 Department Highest Salary SQL SQL SQL - - -
185 Department Top Three Salaries SQL SQL SQL - - -
189 Rotate Array Python, Java $O(n)$ $O(1)$ - - -
190 Reverse Bits Python, Java $O(1)$ $O(1)$ - - -
191 Number of 1 Bits Python $O(\log_{10} n)$ $O(1)$ - - -
192 Word Frequency Shell SHELL SHELL - - -
193 Valid Phone Numbers Shell SHELL SHELL - - -
194 Transpose File Shell SHELL SHELL - - -
195 Tenth Line Shell SHELL SHELL - - -
196 Delete Duplicate Emails SQL SQL SQL - - -
197 Rising Temperature SQL SQL SQL - - -
198 House Robber Python $O(n)$ $O(n)$ DP - -
200 Number of Islands Python, Java $O(n*m)$ $O(n*m)$ DFS - -
201 Bitwise AND of Numbers Range Python, Java $O(\log_{2} n)$ $O(1)$ - - -
206 Reverse Linked List Python $O(n)$ $O(1)$ - - -
207 Course Schedule Python - - - - -
209 Minimum Size Subarray Sum Python, Java $O(n)$ $O(1)$ - - -
217 Contains Duplicate Python, Java $O(n)$ $O(n)$ - - -
219 Contains Duplicate II Python, Java $O(n)$ $O(n)$ - - -
222 Count Complete Tree Nodes Python $O(\log_{2}^{2} n)$ $O(\log_{2} n)$ - - -
223 Rectangle Area Python $O(1)$ $O(1)$ Math - -
226 Invert Binary Tree Python, Java $O(n)$ $O(n)$ - - -
234 Palindrome Linked List Python $O(n)$ $O(1)$ - - -
235 Lowest Common Ancestor of a Binary Search Tree Python $O(n)$ $O(n)$ - - -
237 Delete Node in a Linked List Python, Java $O(1)$ $O(1)$ - - -
242 Valid Anagram Python $O(max(n,m))$ $O(n+m)$ - - -
258 Add Digits Python $O(1)$ $O(1)$ - - -
263 Ugly Number Python $O(\log_{2} n)$ $O(1)$ - 99.59% 60.80%
278 First Bad Version Python, Java $O(\log_{2} n)$ $O(1)$ - - -
279 Perfect Squares Python $O(n*\sqrt{n})$ $O(n)$ - - -
283 Move Zeroes Python $O(n)$ $O(1)$ - - -
290 Word Pattern Python $O(n)$ $O(n)$ - - -
292 Nim Game Python, Java $O(1)$ $O(1)$ Math - -
297 Serialize and Deserialize Binary Tree Python $O(n)$ $O(n)$ Preorder - -
300 Longest Increasing Subsequence Python $O(n*\log_{2} n)$ $O(n)$ - - -
304 Range Sum Query 2D - Immutable Python $O(n*m) + O(1)$ $O(n*m) + O(1)$ - - -
307 Range Sum Query - Mutable Python $O(n * \log_{2} n) + O(\log_{2} n)$ $O(n) + O(1)$ - - -
326 Power of Three Python $O(1)$ $O(1)$ - - -
329 Longest Increasing Path in a Matrix Python $O(n * m)$ $O(n * m)$ - - -
334 Increasing Triplet Subsequence Python, Java $O(n)$ $O(1)$ - - -
336 Palindrome Pairs Python $O(n * k^{2})$ $O(n)$ - - -
342 Power of Four Python $O(1)$ $O(1)$ - - -
345 Reverse Vowels of a String Python $O(n)$ $O(n)$ - - -
365 Water and Jug Problem Python $O(\log_{2} max(n, m))$ $O(\log_{2} max(n, m))$ - - -
374 Guess Number Higher or Lower Python $O(\log_{2} n)$ $O(1)$ - 75.79% 66.34%
377 Combination Sum IV Python $O(2^{n})$ $O(n)$ - - -
383 Ransom Note Python, Java $O(n+m)$ $O(n+m)$ - - -
387 First Unique Character in a String Python $O(n)$ $O(1)$ - - -
390 Elimination Game Python, Java $O(\log_{2} n)$ $O(\log_{2} n)$ - - -
393 UTF-8 Validation Python $O(n)$ $O(1)$ - - -
412 Fizz Buzz Python, Java $O(n)$ $O(1)$ - - -
417 Pacific Atlantic Water Flow Python $O(n * m)$ $O(n * m)$ DFS - -
424 Longest Repeating Character Replacement Python $O(n)$ $O(1)$ - - -
429 N-ary Tree Level Order Traversal Python $O(n)$ $O(n)$ - - -
433 Minimum Genetic Mutation Python $O(n*m^{2})$ $O(n)$ - - -
443 String Compression Python $O(n)$ $O(1)$ - - -
452 Minimum Number of Arrows to Burst Balloons Python $O(n * \log_{2} n)$ $O(1)$ Greedy - -
463 Island Perimeter Python, Java $O(n*m)$ $O(1)$ - 94.28% 94.13%
468 Validate IP Address Python $O(1)$ $O(1)$ RegEx - -
491 Non-decreasing Subsequences Python $O(n^{2})$ $O(n^{2})$ - - -
494 Target Sum Python $O(n*t)$ $O(n*t)$ - - -
495 Teemo Attacking Python $O(n)$ $O(1)$ - - -
497 Random Point in Non-overlapping Rectangles Python $O(n) + O(\log_{2} n)$ $O(n) + O(1)$ - - -
506 Relative Ranks Python $O(n * \log_{2} n)$ $O(n)$ - - -
508 Most Frequent Subtree Sum Python $O(n)$ $O(n)$ - - -
511 Game Play Analysis I SQL SQL SQL - - -
520 Detect Capital Python $O(n)$ $O(1)$ - - -
523 Continuous Subarray Sum Python, Java $O(n)$ $O(n)$ - 95.90% 91.04%
543 Diameter of Binary Tree Python $O(n)$ $O(n)$ - - -
547 Number of Provinces Python $O(n^{2})$ $O(n)$ DSU - -
551 Student Attendance Record I Python, Java $O(n)$ $O(1)$ - 100.00% 91.95%
557 Reverse Words in a String III Python, Java $O(n)$ $O(n)$ - 99.26% 48.16%
560 Subarray Sum Equals K Python $O(n)$ $O(n)$ - - -
565 Array Nesting Python $O(n)$ $O(n)$ - - -
575 Distribute Candies Python, Java $O(n)$ $O(n)$ - - -
584 Find Customer Referee SQL SQL SQL - - -
586 Customer Placing the Largest Number of Orders SQL SQL SQL - - -
592 Fraction Addition and Subtraction Python $O(n)$ $O(n)$ - - -
595 Big Countries SQL SQL SQL - - -
596 Classes More Than 5 Students SQL SQL SQL - - -
598 Range Addition II Python, Java $O(n)$ $O(1)$ - - -
606 Construct String from Binary Tree Python $O(n)$ $O(n)$ - - -
607 Sales Person SQL SQL SQL - - -
608 Tree Node SQL SQL SQL - - -
609 Find Duplicate File in System Python $O(n*k)$ $O(n*k)$ - - -
620 Not Boring Movies SQL SQL SQL - - -
622 Design Circular Queue Python $O(k) / O(1)$ $O(k) / O(1)$ - - -
623 Add One Row to Tree Python $O(n)$ $O(n)$ - - -
627 Swap Salary SQL SQL SQL - - -
637 Average of Levels in Binary Tree Python $O(n)$ $O(\log_{2} n)$ - - -
643 Maximum Average Subarray I Python $O(n)$ $O(1)$ Sliding Window - -
645 Set Mismatch Python $O(n)$ $O(1)$ - 92.30% 74.26%
653 Two Sum IV - Input is a BST Python $O(n)$ $O(h)$ - - -
658 Find K Closest Elements Python $O(k + \log_{2} n)$ $O(1)$ Binary Search - -
659 Split Array into Consecutive Subsequences Python $O(n)$ $O(n)$ - - -
680 Valid Palindrome II Python $O(n)$ $O(1)$ - - -
692 Top K Frequent Words Python $O(n * \log_{2} n)$ $O(n)$ - - -
695 Max Area of Island Python $O(n*m)$ $O(n*m)$ DFS - -
696 Count Binary Substrings Python, Java $O(n)$ $O(1)$ - - -
700 Search in a Binary Search Tree Python $O(n)$ $O(1)$ - - -
704 Binary Search Python $O(\log_{2} n)$ $O(1)$ - - -
717 1-bit and 2-bit Characters Python, Java $O(n)$ $O(1)$ - - -
718 Maximum Length of Repeated Subarray Python $O(n*m)$ $O(n*m)$ DP - -
733 Flood Fill Python $O(n*m)$ $O(n*m)$ DFS - -
747 Largest Number At Least Twice of Others Python $O(n)$ $O(1)$ - - -
748 Shortest Completing Word Python $O(n^{2})$ $O(n^{2})$ - - -
752 Open the Lock Python $O(n)$ $O(n)$ BFS - -
766 Toeplitz Matrix Python $O(n*m)$ $O(1)$ - 71.85% 99.92%
777 Swap Adjacent in LR String Python, Java $O(n)$ $O(1)$ Two Pointers 100.00% 98.78%
788 Rotated Digits Python $O(n * \log_{10} n)$ $O(\log_{10} n)$ - - -
791 Custom Sort String Python $O(n * \log_{2} n)$ $O(n + m)$ - - -
797 All Paths From Source to Target Python $O(n)$ $O(n)$ - - -
802 Find Eventual Safe States Python $O(V+E)$ $O(V)$ - - -
804 Unique Morse Code Words Python $O(n)$ $O(n)$ - - -
811 Subdomain Visit Count Python $O(n*k)$ $O(n*k)$ - - -
814 Binary Tree Pruning Python $O(n)$ $O(n)$ - - -
823 Binary Trees With Factors Python $O(n^{2})$ $O(n)$ - - -
830 Positions of Large Groups Python, Java $O(n)$ $O(1)$ - - -
835 Image Overlap Python $O(n^{4})$ $O(1)$ - 97.08% 52.05%
836 Rectangle Overlap Python $O(1)$ $O(1)$ Math - -
838 Push Dominoes Python $O(n)$ $O(n)$ - - -
841 Keys and Rooms Python $O(n)$ $O(n)$ - - -
844 Backspace String Compare Python $O(min(n,m))$ $O(1)$ - - -
847 Shortest Path Visiting All Nodes Python $O(n^{2}*2^{n})$ $O(n*2^{n})$ BFS - -
860 Lemonade Change Python, Java $O(n)$ $O(1)$ - - -
867 Transpose Matrix Python, Java $O(n*m)$ $O(1)$ - - -
869 Reordered Power of 2 Python $O({\log_{2} n}^{2})$ $O(\log_{2} n)$ - - -
871 Minimum Number of Refueling Stops Python $O(n * \log_{2} n)$ $O(n)$ - - -
872 Leaf-Similar Trees Python $O(H)$ $O(H)$ - 91.29% 87.58%
875 Koko Eating Bananas Python $O(n * \log_{2} M)$ $O(1)$ Binary Search 98.57% 62.98%
876 Middle of the Linked List Python, Java $O(n)$ $O(1)$ - 100.00% 99.73%
877 Stone Game Python, Java $O(1)$ $O(1)$ - - -
886 Possible Bipartition Python $O(V + E)$ $O(V + E)$ DFS - -
890 Find and Replace Pattern Python $O(n*k)$ $O(k)$ - - -
893 Groups of Special-Equivalent Strings Python $O(n * k * \log_{2} k)$ $O(n * k)$ - 93.51% 88.11%
894 All Possible Full Binary Trees Python $O(2^{n})$ $O(2^{n})$ - - -
895 Maximum Frequency Stack Python $O(n)$ $O(n)+O(1)$ - - -
896 Monotonic Array Python $O(n)$ $O(1)$ - 98.61% 94.23%
904 Fruit Into Baskets Python $O(n)$ $O(k)$ - - -
921 Minimum Add to Make Parentheses Valid Python, Java $O(n)$ $O(1)$ - - -
923 3Sum With Multiplicity Python $O(k^{2})$ $O(k)$ - - -
925 Long Pressed Name Python, Java $O(max(n,m))$ $O(1)$ - - -
926 Flip String to Monotone Increasing Python - - - - -
930 Binary Subarrays With Sum Python $O(n)$ $O(n)$ - - -
931 Minimum Falling Path Sum Python $O(n * m)$ $O(1)$ DP 40.57% 92.88%
936 Stamping The Sequence Python $O(m*(m-n))$ $O(m*(m-n))$ - - -
938 Range Sum of BST Python $O(n)$ $O(n)$ DFS - -
944 Delete Columns to Make Sorted Python $O(m * n * \log_{2} n)$ $O(n)$ - - -
946 Validate Stack Sequences Python $O(n)$ $O(n)$ - - -
948 Bag of Tokens Python $O(n * \log_{2} n)$ $O(1)$ Two-pointer - -
954 Array of Doubled Pairs Python - - - - -
959 Regions Cut By Slashes Python $O(n*m)$ $O(n*m)$ DFS - -
967 Numbers With Same Consecutive Differences Python $O(2^{n})$ $O(2^{n})$ DFS - -
976 Largest Perimeter Triangle Python, Java $O(n * \log_{2} n)$ $O(1)$ - - -
977 Squares of a Sorted Array Python $O(n)$ $O(n)$ - - -
980 Unique Paths III Python - - - - -
982 Triples with Bitwise AND Equal To Zero Python $O(n^{3})$ $O(n^{2})$ - - -
985 Sum of Even Numbers After Queries Python, Java $O(n + m)$ $O(1)$ - - -
986 Interval List Intersections Python $O(n+m)$ $O(n+m)$ - - -
988 Smallest String Starting From Leaf Python $O(n)$ $O(n)$ DFS - -
989 Add to Array-Form of Integer Python $O(\log_{10} k)$ $O(1)$ - - -
990 Satisfiability of Equality Equations Python $O(n)$ $O(n)$ - - -
997 Find the Town Judge Python $O(n)$ $O(n)$ - - -
998 Maximum Binary Tree II Python $O(n)$ $O(n)$ - - -
999 Available Captures for Rook Python $O(1)$ $O(1)$ - - -
1006 Clumsy Factorial Python $O(1)$ $O(1)$ - 96.15% 97.93%
1007 Minimum Domino Rotations For Equal Row Python $O(n)$ $O(1)$ - - -
1010 Pairs of Songs With Total Durations Divisible by 60 Python, Java $O(n)$ $O(1)$ - 96.43% 85.53%
1020 Number of Enclaves Python $O(n*m)$ $O(n*m)$ DFS - -
1026 Maximum Difference Between Node and Ancestor Python $O(n)$ $O(n)$ - - -
1030 Matrix Cells in Distance Order Python - - - - -
1039 Minimum Score Triangulation of Polygon Python $O(n^{2})$ $O(n^{2})$ DP - -
1047 Remove All Adjacent Duplicates In String Python $O(n)$ $O(n)$ Stack - -
1048 Longest String Chain Python $O(n*k^{2})$ $O(n)$ - - -
1050 Actors and Directors Who Cooperated At Least Three Times SQL SQL SQL - - -
1071 Greatest Common Divisor of Strings Python $O(n+m)$ $O(n+m)$ - - -
1084 Sales Analysis III SQL SQL SQL - - -
1091 Shortest Path in Binary Matrix Python $O(n^{2})$ $O(n^{2})$ BFS - -
1104 Path In Zigzag Labelled Binary Tree Python $O(\log_{2} n)$ $O(1)$ - 67.53% 73.43%
1114 Print in Order Python CONCURRENCY CONCURRENCY - - -
1131 Maximum of Absolute Value Expression Python $O(n)$ $O(n)$ - - -
1137 N-th Tribonacci Number Python $O(n)$ $O(1)$ - - -
1141 User Activity for the Past 30 Days I SQL SQL SQL - - -
1143 Longest Common Subsequence Python $O(n * m)$ $O(n * m)$ DP 96.32% 81.56%
1148 Article Views I SQL SQL SQL - - -
1155 Number of Dice Rolls With Target Sum Python $O(n*k)$ $O(n*k)$ DP - -
1158 Market Analysis I SQL SQL SQL - - -
1162 As Far from Land as Possible Python $O(n*m)$ $O(n*m)$ - - -
1179 Reformat Department Table SQL SQL SQL - - -
1184 Distance Between Bus Stops Python $O(n)$ $O(1)$ - - -
1207 Unique Number of Occurrences Python $O(n)$ $O(n)$ - 95.89% 72.74%
1220 Count Vowels Permutation Python $O(n)$ $O(1)$ DP - -
1237 Find Positive Integer Solution for a Given Equation Python $O(N + M)$ $O(1)$ - 100.00% 33.63%
1239 Maximum Length of a Concatenated String with Unique Characters Python $O(n^{2})$ $O(n^{2})$ DP 94.14% 8.30%
1249 Minimum Remove to Make Valid Parentheses Python $O(n)$ $O(n)$ - - -
1254 Number of Closed Islands Python $O(n*m)$ $O(n*m)$ DFS - -
1260 Shift 2D Grid Python $O(n^{2})$ $O(n^{2})$ - - -
1275 Find Winner on a Tic Tac Toe Game Python, Java $O(1)$ $O(1)$ - - -
1306 Jump Game III Python $O(n)$ $O(1)$ - - -
1319 Number of Operations to Make Network Connected Python $O(n)$ $O(n)$ - - -
1323 Maximum 69 Number Python $O(n)$ $O(n)$ - - -
1328 Break a Palindrome Python $O(n)$ $O(n)$ - - -
1329 Sort the Matrix Diagonally Python - - - - -
1331 Rank Transform of an Array Python $O(n * \log_{2} n)$ $O(n)$ - - -
1332 Remove Palindromic Subsequences Python, Java $O(n)$ $O(1)$ - - -
1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance Python, Java $O(n^{3})$ $O(n^{2})$ Floyd-Warshall's 100.00% 95.65%
1338 Reduce Array Size to The Half Python $O(n * \log_{2} n)$ $O(n)$ - - -
1342 Number of Steps to Reduce a Number to Zero Python $O(1)$ $O(1)$ Bit Manipulation 96.74% 95.47%
1345 Jump Game IV Python - - - - -
1347 Minimum Number of Steps to Make Two Strings Anagram Python $O(n)$ $O(1)$ - - -
1376 Time Needed to Inform All Employees Python $O(n)$ $O(n)$ DFS - -
1381 Design a Stack With Increment Operation Python - - - - -
1383 Maximum Performance of a Team Python $O(n * \log_{2} n)$ $O(n)$ - - -
1387 Sort Integers by The Power Value Python $O(n * \log_{2} n)$ $O(n)$ - - -
1393 Capital Gain/Loss SQL SQL SQL - - -
1407 Top Travellers SQL SQL SQL - - -
1408 String Matching in an Array Python $O(n^{2}*k^{2})$ $O(1)$ - - -
1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K Python $O(\log_{2} k)$ $O(\log_{2} k)$ - - -
1423 Maximum Points You Can Obtain from Cards Python $O(n)$ $O(1)$ Sliding Window - -
1437 Check If All 1's Are at Least Length K Places Away Python, Java $O(n)$ $O(1)$ - - -
1448 Count Good Nodes in Binary Tree Python $O(n)$ $O(n)$ DFS - -
1457 Pseudo-Palindromic Paths in a Binary Tree Python, Java $O(n)$ $O(n)$ DFS - -
1466 Reorder Routes to Make All Paths Lead to the City Zero Python $O(n)$ $O(n)$ DFS - -
1470 Shuffle the Array Python, Java $O(n)$ $O(1)$ - - -
1472 Design Browser History Python - - - - -
1480 Running Sum of 1d Array Python $O(n)$ $O(1)$ - - -
1484 Group Sold Products By The Date SQL SQL SQL - - -
1493 Longest Subarray of 1's After Deleting One Element Python, Java $O(n)$ $O(1)$ - - -
1496 Path Crossing Python $O(n)$ $O(n)$ - - -
1513 Number of Substrings With Only 1s Python $O(n)$ $O(1)$ - 92.33% 100.00%
1523 Count Odd Numbers in an Interval Range Python - - - - -
1527 Patients With a Condition SQL SQL SQL - - -
1539 Kth Missing Positive Number Python $O(n)$ $O(n)$ - - -
1544 Make The String Great Python $O(n)$ $O(n)$ Stack 94.50% 97.99%
1557 Minimum Number of Vertices to Reach All Nodes Python, Java $O(n)$ $O(n)$ - - -
1576 Replace All ?'s to Avoid Consecutive Repeating Characters Python $O(n)$ $O(n)$ - - -
1578 Minimum Time to Make Rope Colorful Python $O(n)$ $O(1)$ - - -
1581 Customer Who Visited but Did Not Make Any Transactions SQL SQL SQL - - -
1587 Bank Account Summary II SQL SQL SQL - - -
1646 Get Maximum in Generated Array Python $O(n)$ $O(n)$ - - -
1657 Determine if Two Strings Are Close Python $O(n)$ $O(n)$ Sorting 89.60% 94.00%
1662 Check If Two String Arrays are Equivalent Python $O(n)$ $O(1)$ - 99.41% 98.50%
1663 Smallest String With A Given Numeric Value Python $O(n)$ $O(n)$ - - -
1667 Fix Names in a Table SQL SQL SQL - - -
1669 Merge In Between Linked Lists Python $O(n + m)$ $O(1)$ - - -
1672 Richest Customer Wealth Python, Java $O(n*m)$ $O(1)$ - - -
1680 Concatenation of Consecutive Binary Numbers Python $O(n*\log_{2} n)$ $O(1)$ - - -
1684 Count the Number of Consistent Strings Python $O(n+m)$ $O(n+m)$ - - -
1693 Daily Leads and Partners SQL SQL SQL - - -
1729 Find Followers Count SQL SQL SQL - - -
1741 Find Total Time Spent by Each Employee SQL SQL SQL - - -
1752 Check if Array Is Sorted and Rotated Python $O(n)$ $O(1)$ - - -
1757 Recyclable and Low Fat Products SQL SQL SQL - - -
1770 Maximum Score from Performing Multiplication Operations Python $O(m^{2})$ $O(m)$ DP - -
1784 Check if Binary String Has at Most One Segment of Ones Python, Java $O(n)$ $O(1)$ - - -
1795 Rearrange Products Table SQL SQL SQL - - -
1817 Finding the Users Active Minutes Python $O(n)$ $O(n + k)$ Hashing - -
1832 Check if the Sentence Is Pangram Python, Java $O(n)$ $O(1)$ - 92.75% 95.79%
1833 Maximum Ice Cream Bars Python $O(sort)$ $O(n)$ - - -
1839 Longest Substring Of All Vowels in Order Python $O(n)$ $O(1)$ - - -
1848 Minimum Distance to the Target Element Python $O(n)$ $O(1)$ - - -
1869 Longer Contiguous Segments of Ones than Zeros Python - - - - -
1873 Calculate Special Bonus SQL SQL SQL - - -
1876 Substrings of Size Three with Distinct Characters Python, Java $O(n)$ $O(min(n,k))$ Sliding Window - -
1890 The Latest Login in 2020 SQL SQL SQL - - -
1903 Largest Odd Number in String Python $O(n)$ $O(1)$ - - -
1905 Count Sub Islands Python $O(n^{2})$ $O(n^{2})$ DFS - -
1926 Nearest Exit from Entrance in Maze Python $O(n * m)$ $O(n * m)$ BFS 77.25% 55.57%
1945 Sum of Digits of String After Convert Python $O(n)$ $O(n)$ - - -
1962 Remove Stones to Minimize the Total Python $O(n * \log_{2} n)$ $O(1)$ Heap 100.00% 95.88%
1965 Employees With Missing Information SQL SQL SQL - - -
1979 Find Greatest Common Divisor of Array Python, Java $O(n)$ $O(1)$ GCD - -
1984 Minimum Difference Between Highest and Lowest of K Scores Python $O(n*\log_{2} n)$ $O(1)$ - - -
1996 The Number of Weak Characters in the Game Python $O(n * \log_{2} n)$ $O(n)$ - - -
2007 Find Original Array From Doubled Array Python, Java $O(n+k*\log_{2}k)$ $O(k)$ - - -
2022 Convert 1D Array Into 2D Array Python, Java $O(n*m)$ $O(1)$ - - -
2078 Two Furthest Houses With Different Colors Python, Java $O(n)$ $O(1)$ - - -
2095 Delete the Middle Node of a Linked List Python $O(n)$ $O(1)$ - - -
2131 Longest Palindrome by Concatenating Two Letter Words Python - - - - -
2136 Earliest Possible Day of Full Bloom Python $O(n * \log_{2} n)$ $O(n)$ - - -
2185 Counting Words With a Given Prefix Python $O(n*k)$ $O(1)$ - - -
2186 Minimum Number of Steps to Make Two Strings Anagram II Python $O(n+m)$ $O(n+m)$ - - -
2220 Minimum Bit Flips to Convert Number Python, Java $O(\log_{2} n)$ $O(1)$ - 100.00% 97.83%
2225 Find Players With Zero or One Losses Python $O(n * \log_{2} n)$ $O(n)$ - 98.66% 99.40%
2243 Calculate Digit Sum of a String Python $O(\log_{k} n)$ $O(\log_{k} n)$ - - -
2244 Minimum Rounds to Complete All Tasks Python $O(n)$ $O(n)$ Counting - -
2255 Count Prefixes of a Given String Python $O(n*m)$ $O(n*m)$ - - -
2264 Largest 3-Same-Digit Number in String Python $O(n)$ $O(1)$ - - -
2269 Find the K-Beauty of a Number Python $O(\log_{10} n)$ $O(1)$ - - -
2273 Find Resultant Array After Removing Anagrams Python $O(n*k)$ $O(k)$ - - -
2278 Percentage of Letter in String Python, Java $O(n)$ $O(1)$ - - -
2279 Maximum Bags With Full Capacity of Rocks Python $O(n * \log_{2} n)$ $O(n)$ Greedy 99.67% 87.83%
2294 Partition Array Such That Maximum Difference Is K Python, Java $O(n * \log_{2} n)$ $O(1)$ - - -
2299 Strong Password Checker II Python $O(n)$ $O(1)$ - - -
2309 Greatest English Letter in Upper and Lower Case Python $O(1)$ $O(1)$ - - -
2315 Count Asterisks Python $O(n)$ $O(1)$ - - -
2316 Count Unreachable Pairs of Nodes in an Undirected Graph Python $O(n)$ $O(n)$ - - -
2331 Evaluate Boolean Binary Tree Python $O(n)$ $O(n)$ - - -
2335 Minimum Amount of Time to Fill Cups Python $O(1)$ $O(1)$ - - -
2336 Smallest Number in Infinite Set Python $O(1) + O(\log_{2} n)$ $O(n)$ - - -
2337 Move Pieces to Obtain a String Python, Java $O(n)$ $O(1)$ Two Pointers 86.68% 99.25%
2341 Maximum Number of Pairs in Array Python $O(n)$ $O(n)$ - - -
2347 Best Poker Hand Python $O(1)$ $O(1)$ - - -
2348 Number of Zero-Filled Subarrays Python $O(n)$ $O(1)$ Sliding Window - -
2351 First Letter to Appear Twice Python, Java $O(n)$ $O(1)$ - 100.00% 94.36%
2352 Equal Row and Column Pairs Python $O(n^{3}) / O(n^{2})$ $O(1) / O(n)$ - - -
2357 Make Array Zero by Subtracting Equal Amounts Python $O(n)$ $O(n)$ - - -
2359 Find Closest Node to Given Two Nodes Python $O(n)$ $O(n)$ DFS - -
2363 Merge Similar Items Python $O(n*\log_{2} n)$ $O(n)$ - - -
2364 Count Number of Bad Pairs Python $O(n)$ $O(n)$ - - -
2367 Number of Arithmetic Triplets Python $O(n)$ $O(n)$ - - -
2373 Largest Local Values in a Matrix Python $O(n^{2})$ $O(1)$ - - -
2374 Node With Highest Edge Score Python $O(n)$ $O(n)$ - - -
2379 Minimum Recolors to Get K Consecutive Black Blocks Python $O(n)$ $O(k)$ - - -
2380 Time Needed to Rearrange a Binary String Python $O(n)$ $O(1)$ - - -
2383 Minimum Hours of Training to Win a Competition Python, Java $O(n)$ $O(1)$ - - -
2384 Largest Palindromic Number Python $O(1)$ $O(1)$ - - -
2389 Longest Subsequence With Limited Sum Python $O(n*\log_{2} n)$ $O(n)$ - - -
2390 Removing Stars From a String Python - - - - -
2391 Minimum Amount of Time to Collect Garbage Python $O(n)$ $O(1)$ - - -
2395 Find Subarrays With Equal Sum Python $O(n)$ $O(n)$ - - -
2396 Strictly Palindromic Number Python $O(1)$ $O(1)$ - - -
2399 Check Distances Between Same Letters Python $O(1)$ $O(1)$ - - -
2401 Longest Nice Subarray Python, Java $O(n)$ $O(1)$ Sliding Window - -
2404 Most Frequent Even Element Python, Java $O(n)$ $O(n)$ - - -
2405 Optimal Partition of String Python, Java $O(n)$ $O(1)$ - - -
2406 Divide Intervals Into Minimum Number of Groups Python $O(n)$ $O(n)$ - - -
2409 Count Days Spent Together Python $O(1)$ $O(1)$ - - -
2413 Smallest Even Multiple Python, Java $O(1)$ $O(1)$ - - -
2414 Length of the Longest Alphabetical Continuous Substring Python $O(n)$ $O(1)$ - - -
2418 Sort the People Python $O(n * \log_{2} n)$ $O(n)$ - - -
2419 Longest Subarray With Maximum Bitwise AND Python $O(n)$ $O(1)$ - - -
2424 Longest Uploaded Prefix Python $O(1)$ $O(n)$ - - -
2427 Number of Common Factors Python $O(min(n,m))$ $O(1)$ - - -
2428 Maximum Sum of an Hourglass Python $O(n*m)$ $O(n*m)$ - - -
2432 The Employee That Worked on the Longest Task Python $O(n)$ $O(1)$ - - -
2433 Find The Original Array of Prefix Xor Python, Java $O(n)$ $O(1)$ - - -
2441 Largest Positive Integer That Exists With Its Negative Python $O(n) / O(n * \log_{2} n)$ $O(n) / O(1)$ - 98.91% 99.35%
2442 Count Number of Distinct Integers After Reverse Operations Python, Java $O(n)$ $O(n)$ - 99.69% 96.65%
2446 Determine if Two Events Have Conflict Python $O(1)$ $O(1)$ - 89.91% 75.19%
2447 Number of Subarrays With GCD Equal to K Python, Java $O(n^{2} * \log_{2} m)$ $O(1)$ GCD 98.08% 95.20%
2448 Minimum Cost to Make Array Equal Python, Java $O(n * \log_{2} m)$ $O(1)$ Binary Search 99.41% 98.81%
2455 Average Value of Even Numbers That Are Divisible by Three Python $O(n)$ $O(1)$ - 100.00% 85.71%
2482 Difference Between Ones and Zeros in Row and Column Python $O(n * m)$ $O(n + m)$ - - -
2485 Find the Pivot Integer Python $O(√n)$ $O(1)$ Math 99.78% 97.40%
2487 Remove Nodes From Linked List Python - - - - -
2490 Circular Sentence Python $O(n)$ $O(1)$ - - -
2491 Divide Players Into Teams of Equal Skill Python - - - - -
2501 Longest Square Streak in an Array Python $O(n * √n)$ $O(n)$ - - -
2506 Count Pairs Of Similar Strings Python $O(n*m)$ $O(1)$ - - -
2522 Partition String Into Substrings With Values at Most K Python - - - - -
2525 Categorize Box According to Criteria Python $O(1)$ $O(1)$ - - -
2529 Maximum Count of Positive Integer and Negative Integer Python $O(\log_{2} n)$ $O(1)$ - - -
2549 Count Distinct Numbers on Board Python - - - - -
2563 Count the Number of Fair Pairs Python - - - - -
2574 Left and Right Sum Differences Python - - - - -

Last update

Solution table for problems was generated automatically on 2024-05-26 12:09 +0000

About

This is a repository with solutions to LeetCode problems, mainly in Python and SQL. It contains an auto-generated table of all solutions with links to the solution, problem, and BigO time and memory analysis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published