Two Sum
Reported by candidates from Akuna Capital's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Akuna Capital OA reported in September 2026 hands you a twist on a classic: return any pair [i, j] with i < j, or [-1, -1] if nothing works. That fallback is the detail people skim past. It's Two Sum, a hash-table problem, and with up to 10^5 elements the brute force pair scan won't survive. If you've seen it before, you're fine. If you blank under the clock, StealthCoder is the invisible safety net running during the live OA. Know the one-pass map approach cold and this is a quick win.
The problem
Given an integer array nums and an integer target, return any pair of indices [i, j] such that i < j and nums[i] + nums[j] = target. If several valid pairs exist, you may return any one of them. If no valid pair exists, return [-1, -1]. Function twoSum(nums: int[], target: int) → int[] Examples Example 1 nums = [2,7,11,15] target = 9 return = [0,1] nums[0] + nums[1] = 2 + 7 = 9, and 0 < 1. Example 2 nums = [1,2,3] target = 7 return = [-1,-1] No pair of distinct indices has values that sum to 7. Constraints 1 <= nums.length <= 10^5. -10^9 <= nums[i] <= 10^9. -10^9 <= target <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a single pass with a hash map from value to index. For each element, compute complement = target - nums[i]. If the complement is already in the map, return [map[complement], i]. That ordering guarantees i < j automatically. Otherwise store nums[i] and move on. If the loop ends, return [-1, -1]. That's O(n) time and O(n) space. The pitfalls are small but real. Insert after checking, not before, or an element can pair with itself when target is twice its value. Values and target reach 10^9 in magnitude, so the difference can hit 2*10^9 and overflow a 32-bit int in some languages. Use a 64-bit type there. Don't sort, because that loses the original indices. If the assessment clock gets tight and your mind goes blank, StealthCoder can surface this exact approach live, but the logic is short enough to rehearse tonight.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Two Sum cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as two sum. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Akuna Capital's OA.
Akuna Capital reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Two Sum FAQ
How hard is the Akuna Capital Two Sum question really?+
Easy if you know the hash map pattern, and it's the standard version. The only extras are the i < j requirement and the [-1, -1] return for no match. Both fall out naturally from a one-pass map solution, so expect a short implementation.
What's the trick to solving it fast?+
Store each value's index in a hash map as you scan. For each number, check whether target minus that number is already stored. If it is, return the stored index and the current one. That's one pass, O(n), and no sorting needed.
Why can't I just use two nested loops?+
With nums.length up to 10^5, nested loops mean around 5 billion pair checks in the worst case. That will time out on large hidden tests. The hash map version does the same job in linear time, so it's the one you want to submit.
What edge cases should I test before submitting?+
Test a single-element array, which must return [-1, -1]. Test duplicates like [3,3] with target 6, negative numbers, and a target of 0. Also check that one element never pairs with itself, which is why you check the map before inserting.
How do I prepare for this in 48 hours?+
Write the one-pass hash map solution from memory two or three times in your OA language. Then run the edge cases above by hand. Spend the rest of your time on other hash-table and array problems, since the OA may include more than this one question.