Amazon SDE II | AWS Technical Phone Screen | OOP + Discounts (REJECTED)
Company: Amazon
Role: SDE II
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
Hello,
I recently did a technical interview with AWS and was asked something that seemed more OOP (object oriented programming) rather than traditional algorithms + data structures.
The problem statement was something like:
Amazon Marketplace wants to apply a discount for a user's order.
If it's the user's 100th order, there is a discount of 10%.
If the order total exceeds $100, there is a discount of 5%.
They want to apply the highest discount only, e.g. if a user is eligible for both of the above discounts, they only receive the 10% discount.
I basically implemented the function to return the max discount but it seemed like this was far from perfect, since the interviewer later mentioned "what if there is a prime day discount" and was basically nudging me in the direction of using an interface and implementing something like "Discount Rules" where the Discounts class doesn't have knowledge of all the static discounts per case, etc.
Can anyone please guide me on how to practice for these OOP style questions? I feel like there aren't many on Leetcode and it's kind of hard to go about practicing these.
Or if you have any ideas of how you would solve the above in an extensible way, please let me know.