Level: Unknown Level
Round: Online Assessment · Type: Coding · Difficulty: 6/10 · Duration: 60 min · Interviewer: Neutral
Topics: Algorithms, Lexicographical Order, AI
Location: San Francisco Bay Area
Interview date: 2026-01-15
I had two questions on the online assessment. The first involved optimizing the order of boxes based on specific rules.
The first question involved optimizing the arrangement of boxes based on their IDs. The problem statement is as follows:
The team at an Amazon warehouse is given a task to optimize the packing of a set of boxes with different IDs. Each box is labeled with an ID, and these boxes are currently arranged in a single row from left to right, where the ID of the ith box is represented by the string boxIds consisting of digits from 0 to 9 inclusive. To make the packing more efficient, the team can perform the following operation any (possibly zero) number of times: Choose an index i and remove the digit boxIds[i]. Then insert the box with ID min(boxIds[i] + 1, 9) on any position (at the beginning, at the end, or in between any two adjacent boxes) in the row. Given a string boxIds, find the lexicographically minimal string of boxes using these operations. Note:A string X is lexicographically smaller than a string Y of the same length if and only if: In the first position where X and Y differ, the string X has a smaller digit than the corresponding digit in Y. Example: Given: boxIds = “26547" (Delete 5 and insert 6 in the 4th position of the string → Delete 6 from the 2nd position and insert 7 in the 4th position of the string) Hence, the string returned is: "24677" It can be proved that this is the lexicographically minimal string possible. Function Description: Complete the function optimizeBoxIds in the editor below. optimizeBoxIds has the following parameter: string boxIds: the ID of the boxes Returns string: the lexicographically minimal string Constraints 1≤∣boxIds∣≤2×10^5 boxIds consists of only digits from 0 to 9. Note that boxIds is just a string consisting of digits, so leading zeros are allowed.
The second question involved fixing bugs in a loan software repository using an AI assistant. There were three known issues:
After fixing the issues, only 5 out of 6 tests passed. The failing test case involved users repaying loans with insufficient balance. I did not have time to fix this, as the problem description only mentioned fixing the 'fund loan' issue, not the 'repay loan' issue. With only 5 minutes remaining, I decided to submit the code as is, fearing I would not have time to test the new fix.