Changyu Lee

167. Two Sum II - Input Array Is Sorted

Published at
2025/11/08
Last edited time
2025/11/09 05:46
Created
2025/11/09 05:44
Section
NC/LC
Status
Done
Series
Coding Test Prep
Tags
Programming
AI summary
Keywords
Coding Test
Language
ENG
Week

Initial Solution

Time complexity and Space Complexity

Time Complexity: O(n) - In the worst case, we traverse the array once using two pointers that move towards each other.
Space Complexity: O(1) - We only use a constant amount of extra space for the two pointers (i and q).