ZETWERK Hiring Challenge | Interview Question | Off-Campus OA (2024)

Question · Posted Jun 2026

Problem: Take Gifts From the Richest Pile You are given an integer array gifts where gifts[i] represents the number of gifts in the i-th pile. Every second: Choose the pile with the maximum number of gifts. Leave behind ⌊√pile⌋ gifts. Repeat this process exactly k times. Return the total number of gifts remaining after k operations. Example Input gifts = [25,64,9,4,100] k = 4 Output 29 Explanation Initial piles: [25,64,9,4,100] Operation 1 100 → floor(√100) = 10 Piles: [25,64,9,4,10] Operation ...

The full answer & interview discussion are available to premium members.

Log in Create a free account