JPMorgan Coding Interview Questions
25 JPMorgan coding interview problems with full optimal solutions — 14 easy, 10 medium, 1 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an JPMorgan interviewer values, and a FAQ section.
- #1easyfoundational
1. Two Sum
Two Sum is the canonical JPMorgan SDE phone-screen warm-up: given an integer array and a target, return the indices of the two numbers that add up to the target. JPMorgan interviewers grade your willingness to narrate the brute-force-to-optimal tradeoff before writing the hash-map version.
3 free resourcesSolve → - #2mediumfrequently asked
2. Add Two Numbers
Add two non-negative integers stored as singly linked lists in reverse-digit order. JPMorgan asks this on SDE onsites as the linked-list version of the carry-propagation pattern — they specifically grade whether you can fold three loops (both lists, leftover digits, final carry) into one clean loop.
3 free resourcesSolve → - #11mediumfrequently asked
11. Container With Most Water
Given heights of vertical lines, find the two that form the rectangle with the largest water volume. JPMorgan asks this on SDE onsites because the two-pointer move-the-shorter-side argument is the canonical place to grade your invariant-narration skill.
3 free resourcesSolve → - #13easyfrequently asked
13. Roman to Integer
Convert a Roman-numeral string to its integer value. JPMorgan asks this on Software Engineer Programme phone screens because the subtraction rule (IV = 4, IX = 9) makes it the smallest interesting case-by-case parser — a clean check on careful conditional handling.
3 free resourcesSolve → - #14easyfrequently asked
14. Longest Common Prefix
Given an array of strings, return the longest common prefix shared by all of them. JPMorgan asks this on Software Engineer Programme phone screens as a string-processing warm-up that doubles as a check on edge-case handling (empty list, single-string list, no common prefix).
3 free resourcesSolve → - #15mediumfrequently asked
15. 3Sum
Find all unique triplets (a, b, c) in an integer array such that a + b + c = 0. JPMorgan asks this on SDE onsites as the natural Two-Sum follow-up — the grading signal is correct duplicate handling on both the outer fix-one loop and the inner two-pointer walk.
3 free resourcesSolve → - #20easyfoundational
20. Valid Parentheses
Given a string of brackets, decide whether every opener is matched by the correct closer in the right order. JPMorgan asks this as a phone-screen warm-up on the Software Engineer Programme because it is the smallest interesting use of an explicit stack and the easiest place to grade off-by-one mistakes.
3 free resourcesSolve → - #21easyfrequently asked
21. Merge Two Sorted Lists
Merge two sorted linked lists into one sorted list. JPMorgan asks this on Software Engineer Programme phone screens because it tests pointer manipulation cleanly and sets up natural follow-ups (merge k lists, merge sorted arrays).
3 free resourcesSolve → - #35easyfrequently asked
35. Search Insert Position
Given a sorted array and a target, return the index where target is found, or the index at which it would be inserted. JPMorgan asks this on Software Engineer Programme phone screens to verify clean binary-search bounds reasoning before moving to harder follow-ups.
3 free resourcesSolve → - #49mediumfrequently asked
49. Group Anagrams
Group an array of strings such that strings that are anagrams of one another sit together. JPMorgan asks this on SDE onsites to test whether you choose the right canonical key (sorted string vs character-count tuple) and reason about the tradeoffs.
3 free resourcesSolve → - #53mediumcompany favorite
53. Maximum Subarray
Find the contiguous subarray with the largest sum. JPMorgan asks this on quant-research and equities-tech loops because the optimal Kadane's algorithm is one line of state and maps directly to 'largest cumulative P&L window' on a returns series.
3 free resourcesSolve → - #54mediumfrequently asked
54. Spiral Matrix
Return all elements of a matrix in spiral order. JPMorgan asks this on SDE onsites to test whether you can manage four moving boundaries (top, bottom, left, right) without falling into the off-by-one trap that hits 80% of candidates.
3 free resourcesSolve → - #66easyfrequently asked
66. Plus One
Increment by one a non-negative integer represented as a digit array. JPMorgan asks this on Software Engineer Programme phone screens as a low-cognitive-load problem that grades carry-propagation correctness and edge-case handling on a leading 9.
3 free resourcesSolve → - #70easyfrequently asked
70. Climbing Stairs
Count the distinct ways to climb n stairs, taking 1 or 2 steps at a time. JPMorgan asks this on Software Engineer Programme phone screens as the simplest dynamic-programming problem — your willingness to recognise the Fibonacci recurrence is the grading signal.
3 free resourcesSolve → - #121easycompany favorite
121. Best Time to Buy and Sell Stock
Given a day-indexed price array, find the maximum profit from one buy and one later sell. JPMorgan asks this on nearly every market-data and equities-tech SDE loop because the optimal single-pass min-tracking solution generalises directly to streaming P&L computation.
3 free resourcesSolve → - #122mediumfrequently asked
122. Best Time to Buy and Sell Stock II
Same setup as LC 121, but you may buy and sell as many times as you like (no more than one stock at a time). JPMorgan asks this as the natural follow-up on equities and markets-tech loops to test whether you can spot the 'sum every positive day-over-day delta' insight.
3 free resourcesSolve → - #136easyfrequently asked
136. Single Number
Find the one integer that appears once in an array where every other element appears twice. JPMorgan asks this on Software Engineer Programme phone screens to test whether you reach for the XOR trick or default to a hash set — the bit-level insight is the grading signal.
3 free resourcesSolve → - #206easyfrequently asked
206. Reverse Linked List
Reverse a singly linked list. JPMorgan asks this on Software Engineer Programme phone screens to verify you can manipulate pointers safely without losing the next reference — a foundational signal before any harder linked-list follow-up.
3 free resourcesSolve → - #238mediumfrequently asked
238. Product of Array Except Self
For each index, compute the product of all other elements without using division and in O(n) time. JPMorgan asks this on SDE onsites because the optimal prefix-and-suffix-product solution is the smallest interesting use of the 'two passes with O(1) extra space beyond the output' pattern.
3 free resourcesSolve → - #239hardfrequently asked
239. Sliding Window Maximum
For an array and window size k, return the maximum of each contiguous k-window. JPMorgan asks this on senior SDE and quant-tech loops because the monotonic-deque solution is the canonical example of amortised O(n) and maps directly to streaming-max on a tick feed.
3 free resourcesSolve → - #283easyfrequently asked
283. Move Zeroes
In-place move every zero to the end of an array while keeping non-zero values in their original order. JPMorgan asks this as a Software Engineer Programme phone-screen warm-up to see whether you reach for two-pointer over-write before allocating a new array.
3 free resourcesSolve → - #287mediumfrequently asked
287. Find the Duplicate Number
Given an array of n+1 integers in the range [1, n], find the one duplicate without modifying the array and in O(1) extra space. JPMorgan asks this on SDE onsites to test whether you spot the linked-list cycle interpretation — the Floyd's tortoise-and-hare answer is the canonical optimal.
3 free resourcesSolve → - #322mediumfrequently asked
322. Coin Change
Given coin denominations and a target amount, return the minimum number of coins needed (or -1 if impossible). JPMorgan asks this on SDE onsites because it is the canonical unbounded-knapsack DP — your willingness to articulate the state and transition is the grading axis.
3 free resourcesSolve → - #387easyfrequently asked
387. First Unique Character in a String
Return the index of the first non-repeating character in a string. JPMorgan asks this on Software Engineer Programme phone screens as a frequency-map warm-up that primes for the streaming follow-up: 'now imagine characters arrive one at a time'.
3 free resourcesSolve → - #509easyfoundational
509. Fibonacci Number
Compute the n-th Fibonacci number where F(0)=0, F(1)=1, F(n)=F(n-1)+F(n-2). JPMorgan asks this on early-career and intern phone screens to test whether you can recognise the recurrence and pivot from naive recursion to O(n) iteration in under a minute.
3 free resourcesSolve →