There are many ways to compare strings in strs. I just used vertical scanning and horizontal scanning, because I think the other methods are more complexity and harder to understand. Both solution 1 and solution 2 are vertical scanning. I found solution 2 online. “while true”, “try”, and “except” are use in solution 2. Solution …
Category Archives: Uncategorized
LeetCode 26 – Python 3 (Week 5 – 05)
Solution 1 Time complexity is O(n). Space complexity is O(1). Solution 2 Time complexity is O(n). Space complexity is O(1).
LeetCode 13 – Python 3 (Week 5 – 04)
Solution 1 Time complexity is O(n). Space complexity is O(1).
LeetCode 7 – Python 3 (Week 5 – 03)
Solution 1 The integers within the 32-bit signed integer range: [−231, 231 − 1]. Time complexity is O(logx). Space complexity is O(1).
LeetCode 617 – Python 3 (Week 5 – 02)
Solution 1 Time complexity is O(n). Space complexity is O(m). n is the minimum number of nodes from the two given trees. m is the depth. Solution 2 Time complexity is O(n). Space complexity is O(n).
LeetCode 581 – Python 3 (Week 5 – 01)
Solution 1 Time complexity is O(nlogn). Space complexity is O(n). Solution 2 Time complexity is O(n). Space complexity is O(1).
LeetCode 595 – MySQL (Week 4 – 06)
Solution 1 Solution 2 We also can use UNION. I think it’s not necessary.
LeetCode 543 – Python 3 (Week 4 – 05)
Solution 1 Time complexity is O(n). Space complexity is O(n).
Convert BST to Greater Tree – Python 3 (Week 4 – 04)
The third solution is tricky and slow. But its space complexity is O(n). Solution 1 Time complexity is O(n). Space complexity is O(n). Solution 2 Time complexity is O(n). Space complexity is O(n). Solution 3 Time complexity is O(n). Space complexity is O(1).
LeetCode 442 – Python 3 (Week 4 – 03)
Solution 1 Time complexity is O(n). Space complexity is O(1).