Find two numbers summing to target without hashmap
Company: Meta
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates array manipulation, index-tracking, and algorithmic problem-solving skills, with emphasis on time and space complexity trade-offs when locating two elements that sum to a given target under input-size constraints.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([2,7,11,15], 9)
Expected Output: [0, 1]
Explanation: Prompt example.
Input: ([3,2,4], 6)
Expected Output: [1, 2]
Explanation: Middle pair.
Input: ([-1,-2,-3,-4,-5], -8)
Expected Output: [2, 4]
Explanation: Negative values.
Hints
- Use deterministic tie-breaking for prompts with multiple valid outputs.
- For design-style APIs, simulate operations with explicit inputs.