This is a verified interview question from Amazon-assessment. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Maximize Perfect Slots" covers key patterns like Arrays.
"Amazon manages a warehouse with sequentially numbered product slots starting from 1. You are given an array inventory[] where inventory[i] is the product ID in ith slot. A perfect slot is a slot where the product ID equals its slot number. You are allowed to perform the following operation any number of times (possibly zero): - Choose any index i, remove the product in the ith slot. - When you remove a product at position i, all products to its right shift one slot to the left. Determine the maximum number of perfect slots achievable after any number of removals."
Join thousands of developers practicing for Amazon-assessment.