Preparing for the JPMorgan Chase Online Assessment ? Below are two core problems you’ll likely encounter, along with step-by-step solutions in Python.

1. Distinct Digit Numbers
Problem: Given a range [n, m], count how many numbers have all distinct digits.
Approach
- For each
numinrange(n, m+1), convert to string. - Use a
setto check iflen(set(digits)) == len(digits). - Increment a counter when digits are unique.
Code
def count_distinct(n, m):
count = 0
for num in range(n, m + 1):
s = str(num)
if len(set(s)) == len(s):
count += 1
return count
# Example
print(count_distinct(10, 25)) # Outputs how many numbers between 10 and 25 have unique digits
2. First k-Winner in Queue Tournament
Problem: Players with integer “potentials” play in a queue. Each round, the front two compete; the higher‐potential wins, increments its consecutive win count, and the loser goes to the back. Find the first player to win k consecutive rounds.
Approach
- Initialize a
dequeof potentials. - Pop the first as
current_winner, setwin_streak = 0. - While
win_streak < k:- Pop
next_player. - If
current_winner > next_player, incrementwin_streak, append loser. - Else, reset
win_streak = 1, swap roles, append loser.
- Pop
- Return
current_winneroncewin_streak == k.
Code
from collections import deque
def first_k_winner(potentials, k):
q = deque(potentials)
current = q.popleft()
streak = 0
while streak < k:
challenger = q.popleft()
if current > challenger:
streak += 1
q.append(challenger)
else:
q.append(current)
current = challenger
streak = 1
return current
# Example
print(first_k_winner([3, 1, 4, 2, 5], 3)) # Winner who wins 3 in a row
Next Steps & Tips
- Practice these patterns on LeetCode or HackerRank.
- Write clean, well-commented code and test edge cases.
- Review JPMorgan’s hiring values and be ready for behavioral questions.
Good luck with your OA! For personalized coaching or mock assessments, contact us.