← J.P. Morgan Interview Insights

J.P. Morgan·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Went through a coding screen for a Software Engineer role at J.P. Morgan. One question, classic array problem, nothing too surprising but it's the kind of thing that trips you up if you go in rusty.

Questions Asked (1)

Q1

Given an array of integers and a target value, return the indices of the two numbers that sum to the target.

Algorithms & Data Structures
Author's notes

Classic Two Sum.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., exactly one solution, cannot use same element twice, array size). Then present a brute-force O(n^2) solution, followed by an optimized O(n) solution using a hash map to store complements. Walk through the algorithm with a small example, and discuss time/space complexity.

Pro tip: In a fintech interview, emphasize edge cases like duplicate values, negative numbers, and large datasets, and mention that the hash map approach is optimal for real-time trading systems where speed is critical.

1. Clarify requirements and constraints

Ask about input size, whether the array is sorted, if there is exactly one solution, and if the same element can be used twice. This shows attention to detail and avoids incorrect assumptions.

2. Discuss brute-force approach

Mention the naive O(n^2) solution using nested loops to check all pairs. Acknowledge its simplicity but highlight inefficiency for large inputs.

3. Propose optimized hash map solution

Explain using a hash map to store each number's index as you iterate. For each element, check if its complement (target - current) exists in the map. If yes, return the indices; otherwise, add the current number and index to the map.

4. Walk through an example

Choose a small array (e.g., [2, 7, 11, 15], target 9) and step through the algorithm to demonstrate correctness and how the map updates.

5. Analyze complexity and edge cases

State that the hash map solution runs in O(n) time and O(n) space. Discuss edge cases: duplicate numbers, negative numbers, no solution, and large arrays.

Key Points to Mention

  • Time and space complexity trade-offs between brute-force and hash map approaches
  • Handling duplicate values correctly (e.g., [3,3], target 6)
  • Ensuring the same element is not used twice (check index before adding to map)
  • Assumption of exactly one solution and how to handle no solution
  • Use of a hash map (dictionary) for O(1) lookups
  • Real-world relevance to financial systems (e.g., low-latency requirements)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.