Two Sum II (Sorted Array) Solution

🚀Day 2/100 – LeetCode Journey Today’s problem: Two Sum II (Sorted Array) 💡Approach (Two Pointer Method) Since the array is sorted, I used two pointers: One at the start (i) One at the end (j) 👉Logic: If nums[i] + nums[j] == target → return answer ✅ If sum is greater → move j-- If sum is smaller → move i++ In this problem, we return 1-based index → so answer is (i + 1, j + 1) ⚡Time Complexity: O(n) → single pass using two pointers 🧠 Space Complexity: O(1) → no extra space used 🙌 Thanks to RAVI KUMAR Sir for guidance! . . #100DaysOfCode #LeetCode #DSA #Java

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories