A totally new question I'd never seen before, and I was the one who got hit with it. I feel like every question in this loop had a pretty large amount of code, so everyone should practice a lot. I think I failed because of the new question and the BQ — I prepared for BQ the Amazon way, but in practice it felt more like a casual conversation, and I wasn't quite ready for that.
Coding round: the classic "translate formula" question, the one where T1 = T4. Small hiccup — the CodeSignal platform broke, and the interviewer made up for it by giving me a few extra minutes afterward. I finished the whole thing and passed it cleanly.
New question:
You're given a string[] where each line looks like "a100|apple|6|123". The first field is the SKU, the second is the item name, the third is the quantity, and the fourth is the price in cents.
Part 1: calculate the total cost of the items in the string[]. The trap was that the test cases had negative numbers — you're supposed to just skip (continue) past them, but the problem statement said to "ignore" them, and in the actual test cases you couldn't really just ignore them.
Part 2: you're given one more string[], where each line looks like "a100|pct|20" or "a100|bxyf|1|2". This represents promotions — "pct" means X% off, and "bxyf" means buy x get y free, with x = 1, y = 2. You need to calculate a discounted price, and if an item has two promotions, you pick whichever one is cheaper. The trap here was that what you're actually calculating is the total price after discount. The interviewer initially told me to calculate the total amount discounted, but eventually realized that was wrong and corrected it to say I needed to calculate the price after discount. This one took a long time.
Part 3: the problem statement for this one was extremely, extremely, extremely hard to understand. Looking back on it afterward, it seems like you add two more fields to the original string[], turning each line into something like "a100|apple|6|123|4|false", where the last two fields are the aisle number and whether the item is frozen. Then you need to sort all the items in the array by aisle number, with frozen items always placed last. They gave two examples where the sorted result should be: apple (aisle 1), cake (aisle 3), frozen pizza (aisle 7), or apple (aisle 7), candy (aisle 2), frozen cake (aisle 1). The interviewer said the input guarantees the frozen items' aisle number is always either at the very front or the very back. What made this one annoying was that the three parts look related but actually aren't — the code doesn't reuse well. The code I extracted for parts 1 and 2 was basically useless for part 3. And on top of everything, part 3's problem statement was genuinely too hard to parse. Since none of the code could be reused, it ended up being a huge amount of code to write.
System design: inventory system.
BQ.
Good luck everyone.
Discussion
Loading comments…