Problem database last updated: June 20, 2025

JJ.P. Morgan logo

J.P. Morgan Coding Interview Questions

76 problems · 27 Easy, 44 Medium, 5 Hard · Ranked #33 of 458

Difficulty breakdown

27 Easy

36% · avg 23%

44 Medium

58% · avg 59%

5 Hard

7% · avg 18%

Top topics

array
56.6%
string
32.9%
sorting
25%1.7x
hash-table
25%
math
19.7%1.6x
dynamic-programming
18.4%

Interview profile

Based on 76 reported problems, J.P. Morgan interviews are easier than average - only 7% Hard compared to 18% across all companies. The majority (58%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, J.P. Morgan puts unusual emphasis on quickselect (2.6% of problems, 2.5x the industry average), greedy (17.1% of problems, 2x the industry average), counting (6.6% of problems, 2x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (56.6%), string (32.9%), sorting (25%), hash-table (25%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 76 problems

Sort Integers by The Number of 1 Bits

Solve

You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or...

EasyVery Likely
arraybit-manipulationsorting

Reaching Points

Solve

Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false othe...

HardVery Likely
math

Least Number of Unique Integers after K Removals

Solve

Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.

MediumVery Likely
arrayhash-tablegreedy

Minimum Suffix Flips

Solve

You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s...

MediumVery Likely
stringgreedy

Remove Colored Pieces if Both Neighbors are the Same Color

Solve

There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color...

MediumVery Likely
mathstringgreedy

Break a Palindrome

Solve

Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string...

MediumVery Likely
stringgreedy

Next Permutation

Solve

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

MediumVery Likely
arraytwo-pointers

Minimum Absolute Difference

Solve

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

EasyVery Likely
arraysorting

Check Whether Two Strings are Almost Equivalent

Solve

Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 i...

EasyVery Likely
hash-tablestringcounting

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumVery Likely
arrayhash-tablestring

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyVery Likely
arraydynamic-programming

Numbers With Repeated Digits

Solve

Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.

HardLikely
mathdynamic-programming

Determine Color of a Chessboard Square

Solve

You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.

EasyLikely
mathstring

Minimum Swaps to Make Strings Equal

Solve

You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can...

MediumLikely
mathstringgreedy

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumLikely
arraysorting

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyLikely
stringstack

Reverse Odd Levels of Binary Tree

Solve

Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.

MediumLikely
treedepth-first-searchbreadth-first-search

Lexicographically Smallest String After a Swap

Solve

Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same par...

EasyLikely
stringgreedy

Lexicographically Smallest String After Applying Operations

Solve

You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.

MediumLikely
stringdepth-first-searchbreadth-first-search

Maximum Number of Points From Grid Queries

Solve

You are given an m x n integer matrix grid and an array queries of size k.

HardLikely
arraytwo-pointersbreadth-first-search

Check if Number Has Equal Digit Count and Digit Value

Solve

You are given a 0-indexed string num of length n consisting of digits.

EasyLikely
hash-tablestringcounting

Display Table of Food Orders in a Restaurant

Solve

Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi]...

MediumLikely
arrayhash-tablestring

Button With Longest Push Time

Solve

You are given a 2D array events which represents a sequence of events where a child pushes a series of buttons on a keyboard. Each events[i] = [indexi, timei] i...

EasyLikely
array

Rotate Image

Solve

You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

MediumLikely
arraymathmatrix

Find Resultant Array After Removing Anagrams

Solve

You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.

EasyLikely
arrayhash-tablestring

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumLikely
two-pointersstringdynamic-programming

Count Numbers with Unique Digits

Solve

Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.

MediumLikely
mathdynamic-programmingbacktracking

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumLikely
hash-tablestringsliding-window

Happy Number

Solve

Write an algorithm to determine if a number n is happy.

EasyLikely
hash-tablemathtwo-pointers

Maximum Product of Two Elements in an Array

Solve

Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)(nums[j]-1).

EasyLikely
arraysortingheap-priority-queue

Climbing Stairs

Solve

You are climbing a staircase. It takes n steps to reach the top.

EasyLikely
mathdynamic-programmingmemoization

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumLikely
stringdynamic-programmingbacktracking

Best Time to Buy and Sell Stock II

Solve

You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

MediumLikely
arraydynamic-programminggreedy

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyLikely
arrayhash-map

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumLikely
arraydivide-and-conquerdynamic-programming

Fizz Buzz

Solve

Given an integer n, return a string array answer (1-indexed) where:

EasyLikely
mathstringsimulation

Maximum Units on a Truck

Solve

You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:

EasyLikely
arraygreedysorting

Intersection of Two Arrays

Solve

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any...

EasyLikely
arrayhash-tabletwo-pointers

Minimum Operations to Make All Array Elements Equal

Solve

You are given an array nums consisting of positive integers.

MediumLikely
arraybinary-searchsorting

Rearrange Array to Maximize Prefix Score

Solve

You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order).

MediumLikely
arraygreedysorting

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumLikely
arrayhash-tableprefix-sum

Coin Change

Solve

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

MediumSometimes
arraydynamic-programmingbreadth-first-search

LRU Cache

Solve

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

MediumSometimes
hash-tablelinked-listdesign

Non-overlapping Intervals

Solve

Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the int...

MediumSometimes
arraydynamic-programminggreedy

Minimum Cost to Make Array Equal

Solve

You are given two 0-indexed arrays nums and cost consisting each of n positive integers.

HardSometimes
arraybinary-searchgreedy

Binary Tree Right Side View

Solve

Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

MediumSometimes
treedepth-first-searchbreadth-first-search

Pascal's Triangle

Solve

Given an integer numRows, return the first numRows of Pascal's triangle.

EasySometimes
arraydynamic-programming

Reverse Linked List

Solve

Given the head of a singly linked list, reverse the list, and return the reversed list.

EasySometimes
linked-listrecursion

Fibonacci Number

Solve

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, startin...

EasySometimes
mathdynamic-programmingrecursion

Daily Temperatures

Solve

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait aft...

MediumSometimes
arraystackmonotonic-stack

Palindrome Number

Solve

Given an integer x, return true if x is a palindrome, and false otherwise.

EasySometimes
math

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumSometimes
arraydivide-and-conquersorting

Spiral Matrix

Solve

Given an m x n matrix, return all elements of the matrix in spiral order.

MediumSometimes
arraymatrixsimulation

Shuffle an Array

Solve

Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffl...

MediumSometimes
arraymathdesign

Letter Combinations of a Phone Number

Solve

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

MediumSometimes
hash-tablestringbacktracking

Decode Ways

Solve

You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping:

MediumSometimes
stringdynamic-programming

Combination Sum

Solve

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...

MediumSometimes
arraybacktracking

Set Matrix Zeroes

Solve

Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.

MediumSometimes
arrayhash-tablematrix

Cherry Pickup

Solve

You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.

HardSometimes
arraydynamic-programmingmatrix

Search Suggestions System

Solve

You are given an array of strings products and a string searchWord.

MediumSometimes
arraystringbinary-search

Find the Duplicate Number

Solve

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

MediumSometimes
arraytwo-pointersbinary-search

Top K Frequent Elements

Solve

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

MediumSometimes
arrayhash-tabledivide-and-conquer

Open the Lock

Solve

You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely...

MediumSometimes
arrayhash-tablestring

Degree of an Array

Solve

Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.

EasySometimes
arrayhash-table

Count Binary Substrings

Solve

Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings...

EasySometimes
two-pointersstring

Two Sum II - Input Array Is Sorted

Solve

Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number....

MediumSometimes
arraytwo-pointersbinary-search

Integer to Roman

Solve

Seven different symbols represent Roman numerals with the following values:

MediumSometimes
hash-tablemathstring

Contains Duplicate

Solve

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

EasySometimes
arrayhash-tablesorting

Find Occurrences of an Element in an Array

Solve

You are given an integer array nums, an integer array queries, and an integer x.

MediumSometimes
arrayhash-table

Permutations

Solve

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

MediumSometimes
arraybacktracking

Minimum String Length After Removing Substrings

Solve

You are given a string s consisting only of uppercase English letters.

EasySometimes
stringstacksimulation

Minimum Insertions to Balance a Parentheses String

Solve

Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:

MediumSometimes
stringstackgreedy

Ugly Number

Solve

An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.

EasySometimes
math

Sum of Subarray Ranges

Solve

You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.

MediumSometimes
arraystackmonotonic-stack

Average Time of Process per Machine

Solve

Table: Activity

EasySometimes
database

Container With Most Water

Solve

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

MediumSometimes
arraytwo-pointersgreedy

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent J.P. Morgan interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your J.P. Morgan coding interview

J.P. Morgan interviews focus heavily on array, string, sorting problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. J.P. Morgan interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does J.P. Morgan ask in interviews?add

J.P. Morgan has been reported to ask 76 distinct coding problems. The most common topics are array, string, sorting. 27 are Easy difficulty, 44 are Medium, and 5 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are J.P. Morgan coding interviews?add

Based on 76 reported problems, J.P. Morgan interviews are easier than average - only 7% Hard compared to 18% across all companies. 58% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a J.P. Morgan coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, sorting. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your J.P. Morgan interview?

Simulate a real J.P. Morgan coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a J.P. Morgan interview with AIarrow_forward