Oh hey that's the question I got for my recent amazon onsite (slightly different constraints). I couldn't find the exact question online and I thought it was a "fair" medium question. IMO this is a pretty good question there's a really easy suboptimal solution so people don't get completely stuck, the optimizations are pretty straightforward and there's a lot of room to demonstrate you can write clean code.
*Fair meaning there's no crazy tricks to it or any obscure algorithms just applying DSA fundamentals.