Company: Amazon_3_Jan

Difficulty: medium

Problem Statement

Smart Cities Security Units Smart Cities Security Units Problem Description In Amazon's Smart Cities Management System, each city has a given population and some cities are equipped with security units. You are given: An integer array population of size n , where population[i] is the number of inhabitants in the i th city. A binary string unit of length n , where unit[i] = '1' means city i has a security unit, and '0' means it does not. Relocation Rule: A security unit at city i (where i > 1 ) can be moved one step to the left to city i - 1 . Each unit can be moved at most once. If moved, city i loses its unit and city i - 1 gains one. City 1's security unit cannot be moved further. A city is protected if it has a security unit after all relocations. Determine the maximum population that can be protected by optimally relocating the security units. Note: The problem uses 1-based indexing, meaning city indices, the population array, and the unit binary string all start from 1 and go up t

More Amazon_3_Jan OA questionsInterview experiences