UBER internship 2023 online assessment

Questio 3 (POINTS-350)
Uber HR is looking to book hotel rooms for an incoming 2023 batch of hired College Graduates. She is allowed to spend anywhere between B and C (both inclusive) for these bookings. She needs to book rooms consecutively as the new joinees would prefer to stay as close to each other as possible.

She has been given the pricing of the rooms in order in the form of array A (Needless to say, the prices are non-negative integers). You need to find out the number of consecutive rooms options available for booking. Note that there is no restriction on the number of rooms she can book. (She can book as less as one or she can book the entire hotel if budget constraints are satisfied)

Constraints:
1 <= size of A <= 10^6
B and C fit in a 32 bit signed integer

Example:

Given A = [10, 5, 1, 0, 2], B = 6, C = 8
Output: 3
Explanation: Possible solutions are [5,1], [5,1,0], [5,1,0,2]

[execution time limit] 0.5 seconds (cpp)

[memory limit] 1 GB

[input] array.integer arr

pricing of the rooms

[input] integer b

lower bound of budget

[input] integer c

Upper bound of budget

[output] integer

possible ways to book rooms within budget

Comments (2)