LeetCode 3903: two solutions - O(n²) vs O(n) Time complexity
We're used to evaluating an algorithm's Time complexity, but we often overlook its Space complexity. However, often the best solution for Time complexity is a brute-force solution for Space complexity and vice versa.
Read more