Spend it All
FULLTIME
There is a budget and an array of n costs. Repeat the following process until budget is less than the minimum element in cost.
Process
Start at element 0 and work to n - 1 . At each element cost[i] :
The array is circular, so the next index after n - 1 is index 0. Continue until there is not enough budget to make a purchase.
Determine how many purchases are made.
Function Description
Complete the function countPurchases in the editor below.
countPurchases has the following parameters:
Returns
Example 1 :
Input: cost = [5, 8, 3], budget = 12
Output: 3
Explanation:
Process:
Constraints:
Get one-to-one training from Google Facebook engineers
Top-notch Professionals
Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.
Customized Private Class
Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.