Daily challenge for 2026-07-29
575. Optimal Quality Control Threshold
You are given an array of positive integers scores representing the quality scores of various products, and an integer target. You need to find the maximum integer threshold T such that the sum of all scores that are greater than or equal to T is at least target. If no such threshold exists (even at T = 0), return -1.
Example:
Input: scores = [1, 2, 5, 9], target = 14
Output: 5
Explanation: For T = 5, the scores greater than or equal to 5 are 5 and 9, which sum to 14. For T = 6, only 9 is >= 6, which sums to 9 (less than target). Thus, the maximum threshold is 5.
Run this challenge interactively in Python or JavaScript when the app loads.