Solution 1 Time complexity is O(n). Space complexity is O(1).
Category Archives: Uncategorized
*LeetCode 437 – Python 3 (Week 4 – 01)
Solution 1 Both time complexity and space complexity are O(n*n) to O(nlogn). Solution 2 Both time complexity and space complexity are O(n).
LeetCode 283 – Python 3 (Week 3 – 08)
Solution 1 Time complexity is O(n). Space complexity is O(1). Solution 2 Time complexity is O(n log n). Space complexity is O(n). Solution 3 Time complexity is O(n). Space complexity is O(1).
LeetCode 234 – Python 3 (Week 3 – 07)
Solution 1 Time complexity is O(n). Space complexity is O(1).
LeetCode 226 – Python 3 (Week 3 – 06)
Solution 1 Time complexity is O(n). Space complexity is O(n). Solution 2 Time complexity is O(n). Space complexity is O(n).
LeetCode 206 – Python 3 (Week 3 – 05)
Solution 1: Iterative Time complexity is O(n). Space complexity is O(1). Solution 2: Recursive Time complexity is O(n). Space complexity is O(n).
LeetCode 155 – Python 3 (Week 3 – 04)
Solution 1 Time complexity and space complexity are O(1). Warning: Do not use ” if not x”, if “x” is a number!
LeetCode 198 – Python 3 (Week 3 – 03)
Solution 1 Time complexity is O(n). Space complexity is O(1).
LeetCode 169 – Python 3 (Week 3 – 02)
Solution 1: Time complexity is O(n). Space complexity is O(n). Solution 2 Time complexity is O(n). Space complexity is O(1). Solution 3 Time complexity is O(nlgn). It is the time to sort array in Python. Space complexity is O(n). Timsort is used.
LeetCode 160 – Python 3 (Week 3 – 01)
Solution 1 Time complexity is O(m+n). Space complexity is O(1).