Background
This was for an Amazon SWE I role on HackerRank. The OA lasted 100 minutes and had two questions. The first involved DP, strings, and inversions; the second was debugging a Django/DRF backend repository. My overall impression was that one tested algorithmic modeling and the other tested engineering debugging and reading code quickly. Their styles were very different, so time allocation mattered a lot.
Overall process
Platform: HackerRank.
Duration: 100 minutes.
Questions: 2.
Q1: An algorithm problem with the function signature getMinimumConflicts(primary, secondary).
Q2: Debug a Django/DRF repository in a web IDE and fix the bugs so all the provided unit tests pass.
Language: Python.
Suggested timing: Try to finish Q1 in 35 to 45 minutes, leaving enough time to read code and run tests for Q2.
Q1: Minimum Merge Conflicts
Type: Dynamic Programming / Strings / Inversions.
What I remember of the problem
There are two version branches, primary and secondary. Each lowercase letter represents a commit's priority; earlier letters have higher priority. Merge the strings into one unified branch while preserving the original relative order within each string.
A conflict occurs when a lower-priority commit appears before a higher-priority commit. Find the fewest conflicts among all valid merges.
Example:
primary = "zc"
secondary = "d"
Valid merges and conflicts:
"zcd": 2
"zdc": 3
"dzc": 2
Output: 2.
Constraints:
1 <= len(primary), len(secondary) <= 1000.
Only lowercase English letters.
Preserve the relative order within both original strings.
Approach
Use DP. dp[i][j] is the minimum conflict count after merging the first i characters of primary and the first j characters of secondary.
For each transition, consider whether the next character comes from primary[i] or secondary[j]. Precomputed prefix counts let you calculate the new conflicts quickly: when appending a character, count how many characters already merged have lower priority.
Time complexity: O(N * M).
Space complexity: O(N + M) with a rolling array and prefix counts.
The important part is expressing conflicts in a way that can be updated incrementally. Otherwise, you end up enumerating every merge. The DP state is not difficult to come up with; calculating the additional conflicts efficiently during transitions is the difficult part.
Q2: Wallet Recurring Payments
Type: Repository Debugging / Backend Engineering.
Stack: Python, Django, Django REST Framework.
What I remember of the problem
Wallet is a digital payment platform supporting transfers, wallet management, and recurring payments. The recurring-payment feature had bugs. I had to locate and fix them so all the provided unit tests passed.
Relevant endpoints:
POST /wallet/{senderPhoneNumber}/recurring_payment/create/
GET /recurring_payments/
Sample request:
{
"receiver_wallet": "example_receiver_wallet",
"amount": 100,
"frequency": "monthly",
"start_date": "2025-09-15",
"end_date": "2026-09-15",
"note": "Test monthly payment"
}
Observed problems:
Creating a recurring payment failed despite valid input and the correct passcode.
Successfully created recurring payments did not appear in the payment list.
Validation requirements:
amount > 0.
start_date <= end_date.
The sender and receiver wallets must differ.
The receiver wallet must exist.
The frequency must be valid.
The sender must have enough balance.
Payment processing
Management command:
python manage.py process_recurring_payments
A payment is due when it is active, the current date is within the start/end range, and there is either no previous payment or enough time has passed since last_payment_date for its frequency.
Daily: 1 day.
Weekly: 7 days.
Monthly: 30 days.
Yearly: 365 days.
Successful processing must transfer the funds, create a transaction record, and update last_payment_date. Insufficient funds should cause the payment to be skipped, and there must be no duplicate charge.
Bugs I located and fixes
Reversed date validation: reject start_date > end_date.
Reversed wallet validation: reject sender_wallet == receiver_wallet.
Zero amounts accepted: reject amount <= 0.
Frequency ignored: check the interval since last_payment_date.
Processing continued despite insufficient funds: return or skip before changing balances.
Payment date not updated: save last_payment_date after success.
Advice after looking back
For Q1, do not start by enumerating merges. Think about the DP state and incremental conflict calculation first.
For Q2, run the tests to see what fails, then read through the endpoint, serializer, model, and management command.
Watch the Django/DRF validation layers: bugs can hide in serializer validation, view logic, model constraints, or the management command.
Be especially careful about insufficient funds and duplicate payments. Check before changing state to avoid partial updates.
Good luck, everyone!
Discussion
Loading comments…