As reported: Visa SDE 1 (India), round 2 — technical (2025): Spring Boot / Java / SQL concepts plus coding: 2-sum, then 3-sum. The interviewer asked why each choice was made while coding.
Given an integer array nums and an integer target, return the indices of the two numbers that add up to target. Exactly one solution exists, and the same element cannot be used twice. Any order of the two indices is accepted.
This is LeetCode 1 — Two Sum.
Example
nums = [2,7,11,15], target = 9 -> [0,1]
nums = [3,2,4], target = 6 -> [1,2]
nums = [3,3], target = 6 -> [0,1]
Constraints: 2 ≤ nums.length ≤ 10^4; -10^9 ≤ nums[i], target ≤ 10^9.
Code runner format: one JSON value per line: nums, then target. Implement twoSum(nums, target); the harness prints the two indices.