O(m+n) time and O(1) extra space.
Category Archives: Uncategorized
LeetCode 74 LintCode 28 – Python 3 (Week 10 – 02)
Solution 1 Time complexity is O(log n*m). Space complexity is O(1). Solution 2 Time complexity is O(log n + log m) = O(log n*m) . Space complexity is O(1).
LeetCode 35 LintCode 60 – Python 3 (Week 10 – 01)
LintCode 637 – Java
LintCode 60 – Java
LeetCode 704 LintCode 14 – Python 3 (Week 09 – 08)
Basic binary search. Time complexity is O(log n). Space complexity is O(1).
LeetCode 91 LintCode 512 – Python 3 (Week 09 – 07)
Solution 1: Use dp Time complexity is O(n). Time complexity is O(1).
LintCode 637 LeetCode 408 – Python 3 (Week 09 – 06)
Time complexity is O(nm). Space complexity is O(1). Pay attention to that abbr[j] is string. The first digit should not be 0.
LintCode 1380 – Python 3 (Week 09 – 05)
Time complexity is O(nlogn). Space complexity is O(1).
LeetCode 56 LintCode 156 – Python 3 (Week 09 – 04)
Time complexity is O(nlogn): sorted(). Space complexity is O(1).