JPMorgan Chase interview prep
10 practice questions on the topics candidates reported from JPMorgan Chase interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
DSA 7
-
Intervals [1, 3], [2, 4], [6, 7], [9, 12] and [11, 13]. Which overlap no other interval (sharing an end point counts as overlapping)?
- [6, 7] only
- [1, 3] and [6, 7]
- [6, 7] and [9, 12]
- None of them
Show the answer
A. [6, 7] only
Sort by start; an interval is isolated when it starts after the largest end seen so far and ends before the next interval starts. [1, 3] and [2, 4] overlap, as do [9, 12] and [11, 13]. Sorting makes it O(n log n).
This topic is named in a candidate’s interview report: Software engineer coding round, 2021, on GeeksforGeeks.
-
Merging the overlapping intervals among [1, 3], [2, 6], [8, 10] and [15, 18] leaves how many intervals?
- 4
- 3
- 2
- 1
Show the answer
B. 3
Sorted by start, [1, 3] and [2, 6] overlap and become [1, 6]; [8, 10] and [15, 18] stand alone. After sorting, one pass that extends the last merged interval or starts a new one: O(n log n).
This topic is named in a candidate’s interview report: Software engineer coding round, 2021, on GeeksforGeeks.
-
Coins of value 1, 3 and 4 are available in any number. To make 6, a greedy method keeps taking the largest coin that still fits. How many coins does greedy use, and how many does the best answer use?
- 2 and 2
- 3 and 3
- 4 and 2
- 3 and 2
Show the answer
D. 3 and 2
Greedy takes 4, then 1 and 1: three coins. Two 3s make 6 with two. Greedy is safe for coin sets like 1, 2, 5, 10 but not for every set, so the general minimum-coins problem is solved with dynamic programming: best[a] = 1 + the smallest best[a - c] over every coin c.
This topic is named in a candidate’s interview report: Software engineer programme HireVue, 2019, on GeeksforGeeks.
-
What is the next permutation of 1 3 5 4 2 in lexicographic order?
- 1 4 5 3 2
- 1 4 2 3 5
- 1 3 5 2 4
- 1 5 2 3 4
Show the answer
B. 1 4 2 3 5
Scan from the right for the first number smaller than the one after it: 3, since 5 4 2 is falling. Swap it with the smallest larger number to its right, 4, giving 1 4 5 3 2, then reverse that falling tail into rising order: 1 4 2 3 5. All in O(n) time and O(1) extra space.
This topic is named in a candidate’s interview report: Code for Good coding round, 2023, on GeeksforGeeks.
-
From [4, 3, 2, 6], repeatedly remove two numbers and put back their sum, until one number is left. Each step costs the sum it puts back. What is the smallest possible total cost?
- 30
- 31
- 29
- 34
Show the answer
C. 29
Always combine the two smallest, using a min-heap: 2 + 3 = 5, then 4 + 5 = 9, then 6 + 9 = 15, for 5 + 9 + 15 = 29. Small numbers are added into every later sum, so they should be combined first; this is the same idea as Huffman coding, O(n log n) in all.
This topic is named in a candidate’s interview report: Code for Good interview, 2022, on GeeksforGeeks.
-
In "00110011", how many substrings (counted by position) have equal numbers of 0s and 1s, with all their 0s together and all their 1s together?
- 4
- 8
- 10
- 6
Show the answer
D. 6
Group the string into runs: 2 zeros, 2 ones, 2 zeros, 2 ones. Each pair of neighbouring runs gives min(a, b) such substrings, so 2 + 2 + 2 = 6: "0011", "01", "1100", "10", "0011" and "01". One pass over the run lengths is O(n).
This topic is named in a candidate’s interview report: Software engineer coding round, 2021, on GeeksforGeeks.
-
Start with 87. Add the number to its digits reversed, and repeat until the result is a palindrome. How many additions does it take, and which palindrome do you reach?
- 2 additions, 727
- 3 additions, 6336
- 4 additions, 4884
- 5 additions, 48884
Show the answer
C. 4 additions, 4884
87 + 78 = 165, 165 + 561 = 726, 726 + 627 = 1353, 1353 + 3531 = 4884, which reads the same both ways. Reverse a number with a loop of n % 10 and n / 10. Some numbers, such as 196, are not known to ever reach a palindrome, so real code caps the number of steps.
This topic is named in a candidate’s interview report: Software engineer programme HireVue, 2019, on GeeksforGeeks.
DBMS and SQL 1
-
When is a document database such as MongoDB usually a better fit than a relational database?
- When many tables must be joined with strict transactions across them
- When the data is a few small tables with a fixed structure
- Whenever the data must survive a restart
- When each record is read and written as a whole and its fields vary from record to record
Show the answer
D. When each record is read and written as a whole and its fields vary from record to record
A document keeps a record and its nested details together without one fixed schema, which suits catalogues, profiles and event logs. Relational databases are stronger when data is shared between tables and changes must span them in one transaction.
This topic is named in a candidate’s interview report: Code for Good interview, 2022, on GeeksforGeeks.
Web development 1
-
In an Express app, a middleware function looks like (req, res, next) => { ... }. What does calling next() do?
- Sends the response
- Restarts the server
- Passes the request on to the next middleware or route handler in the chain
- Retries the request
Show the answer
C. Passes the request on to the next middleware or route handler in the chain
Middleware runs in the order it was added, for jobs like logging, parsing JSON bodies or checking a login. If a middleware neither responds nor calls next(), the request hangs. next(err) skips ahead to the error-handling middleware.
This topic is named in a candidate’s interview report: Code for Good interview, 2022, on GeeksforGeeks.
Software engineering 1
-
What is Kubernetes for?
- Writing Dockerfiles
- Replacing the operating system kernel
- Running containers across a cluster of machines: scheduling them, restarting failed ones, scaling and load-balancing them
- Version control for code
Show the answer
C. Running containers across a cluster of machines: scheduling them, restarting failed ones, scaling and load-balancing them
Docker packages an app into a container image; Kubernetes runs many such containers reliably across servers, declared as desired state (deployments, services) that it keeps true.
This topic is named in a candidate’s interview report: Software engineer programme interview, 2026, on Reddit.