Back to problems

Solve subset-count and kth-factor problems

Algorithm · Amazon · Hard

Solve both parts independently. Part 1 — Largest Selection Within a Sum Budget You are given an integer array arr and a budget n. You may choose any subset of the array positions. The goal is to maximize the number of selected elements while keeping their total sum at most n. Return only that maximum count. The empty selection is allowed and counts as 0. Your Part 1 solution must do all of the following: Give an algorithm that is optimal when every element of arr is…

Checking your access…