SDE2 | TripAdvisor

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-12-17Added By Anonymous
Source: Link

Round 1 :

What is the maximum number of gifts the uncle can buy for his nephew, given a list of gifts available on specific days with their corresponding prices? The uncle receives 1 unit of currency every day, and the list consists of tuples in the format [day, gift price].


For example, [1,3] means that on the first day the uncle’s balance is 1 unit and price of the gift is 3, and [3,2] means that on the balance is 3 units and a gift is available for 2 units. Determine the maximum number of gifts the uncle can purchase with the available amount of money in the bank account.


Sample Case:

[

[1,3], -> not possible

[2,3], -> not possible

[3,2], -> possible

[4,1], -> possible

[5,3] -> not possible

]


Output: 2

Comments