Find Maximum Number of Subjects Passed (AS Intern, but it may apply to other interns) π
Learn this problemProblem statement
Your team at AmzAn is building a quiz-style application to help students prepare for certification exams. Each quiz module tests one or more subjects and limits the number of review attempts each student has been asked to examine. To do this, please review each of the certification exams provide. You have within quiz modules answered[i] questions in each allows students to "pass" certain subjects with a total of q more questions overall. For each answer the following: Imagine a student has already answered needed[i] in order to pass. For each of the n subjects, and still has answered has to be at least pass if the q additional answered of the subject, the number of questions the student can pass determine the maximum number among the subjects. The questions are optimally distributed.
For example, consider that there are n = 2 subjects and needed = [4, 5] answered questions, respectively, to pass. Imagine another q = 1 questions across all subjects combined. In that case, the best outcome is to answer an additional question in the second subject, in order to pass it, as 2 more answers are required to pass the first subject. The maximum number of subjects that can be passed is 1.
Function
findMaximumNum(answered: int[], needed: int[], q: int) β int
Complete the function findMaximumNum in the editor below. The function must return an integer that represents the maximum number of subjects that can be passed.
findMaximumNum has the following parameter(s):
int[] answered: an array of integersint[] needed: an array of integersint q: an integer
κ§ΰΌΊΰΏ ΰ½²ΰ½½β’ Credit to whale and spike! π³ β’ΰΏ ΰ½²ΰ½½ΰΌ»κ§
Examples
Example 1
answered = [24, 27, 0]needed = [51, 52, 100]q = 100return = 2Example 2
answered = [24, 27, 0]needed = [51, 52, 100]q = 200return = 3Example 3
answered = [2, 4]needed = [4, 5]q = 1return = 1Constraints
- 1 β€ n β€ 10^5
- 0 β€ answered[i], needed[i], q β€ 10^9
More Amazon problems
- Secure Maximum DeliveriesOA Β· Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW Β· Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN Β· Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN Β· Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW Β· Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW Β· Seen Jul 2026
- Maximum System Memory CapacityOA Β· Seen Jul 2026
- Package Delivery SystemOA Β· Seen Jul 2026