Two Sum II - Input Array Is Sorted
A medium-tier problem at 63% community acceptance, tagged with Array, Two Pointers, Binary Search. Reported in interviews at EPAM Systems and 11 others.
Two Sum II hits your assessment from companies like Google, Apple, and J.P. Morgan. You already know Two Sum. This one's sorted, which changes everything. The naive hashmap approach still works, but the interviewer wants you to see the two-pointer pattern. If you freeze on optimization during the live OA, StealthCoder surfaces the linear-time solution in seconds, invisible to the proctor. 63% of candidates pass this one, so it's beatable. The trick isn't hard once you see it.
Companies that ask "Two Sum II - Input Array Is Sorted"
Two Sum II - Input Array Is Sorted is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe sorted array is the entire puzzle. Two pointers converge from opposite ends. Start left at index 0, right at the last index. If the sum is too small, move left forward. Too big, move right backward. You hit the target in one pass. No extra space, O(n) time, and you don't need binary search at all. Most candidates either overengineer with binary search or regress to a hashmap. The pattern is fast to code once you've drilled it, but in a live assessment panic, you might blank. That's where StealthCoder steps in. It reads the problem, surfaces the two-pointer solution, and you paste working code.
Pattern tags
You know the problem.
Make sure you actually pass it.
Two Sum II - Input Array Is Sorted recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Two Sum II - Input Array Is Sorted interview FAQ
Is Two Sum II actually easier than Two Sum?+
Not easier, different. Two Sum lets you use a hashmap and brain-off. Two Sum II forces you to exploit the sorted property with two pointers. Conceptually simpler once you see it, but you have to see it first. That's the trap.
Do I really need binary search here?+
No. Binary search works but wastes the sorted property. Two pointers is cleaner, faster to code, and what interviewers expect. If you reach for binary search, you're adding complexity for no reason.
Will Apple or Google ask this exact problem?+
Both are in the top companies asking it. They're testing whether you recognize that sorted input changes the strategy. This version appears frequently in their assessments.
What happens if there's no solution?+
The problem guarantees exactly one solution, so you don't handle no-match. But know the termination condition: when left >= right, you're done. If pointers cross without finding it, something's wrong with the input, not your code.
How does this relate to binary search as a topic?+
Both are in the topic list, but this problem doesn't require it. Binary search is a backup approach if you can't see two pointers. For speed and code clarity, two pointers dominates. Know binary search for other problems, not this one.
Want the actual problem statement? View "Two Sum II - Input Array Is Sorted" on LeetCode →