165.Compare-Version-Numbers
165. Compare Version Numbers
题目地址
题目描述
代码
Approach 1: Split + Parse, Two Pass, Linear Space
Complexity Analysis
Time complexity : O(N+M+max(N,M)), where N and M are lengths of input strings.
Space complexity : O(N+M) to store arrays
nums1
andnums2
.
Approach #2: Two Pointers, One Pass, Constant Space
Complexity Analysis
Time complexity : O(max(N,M)), where Nand M are lengths of the input strings respectively. It's a one-pass solution.
Space complexity :O(1), since we don't use any additional data structure.
Last updated