Member-only story
J.P. Morgan iOS Developer Interview
The 15 Questions That Nearly Broke Me
Round 1: Online Assessment (HackerRank — 90 minutes)
This round was purely code and fundamentals. Two main coding problems + 10 multiple-choice questions on Swift, iOS, and general CS.
DSA Question 1: Fraud Detection in Transactions
Problem:
You receive a list of transactions with (cardNumber, country, timestamp). Detect if the same card is used in two different countries within 5 minutes.
Thought Process:
- Sort transactions by timestamp.
- Store last transaction in a dictionary keyed by card number.
- Compare current with last — if countries differ and time gap ≤ 5 minutes, return true.
Swift Solution:
struct Transaction {
let card: String
let country: String
let time: Date
}
func detectFraud(transactions: [Transaction]) -> Bool {
var lastUse: [String: (String, Date)] = [:]
let sortedTransactions = transactions.sorted { $0.time < $1.time }
for t in sortedTransactions {
if let (lastCountry, lastTime) = lastUse[t.card] {
let diff =…









