Uber Phone Screen: Reject

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-05-15Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

An applicant is playing a game where they encounter n obstacles in a row, each with a difficulty level ai. They can choose a subsegment of obstacles defined by indices 1 ≤ l ≤ r ≤ n, and their character will tackle the obstacles from left to right. The character's difficulty level g starts at 0 and increases by the difficulty level of each obstacle encountered. If g exceeds a given value x, it resets to zero, and the process continues. The applicant wants to know how many subsegments can be chosen such that the final difficulty level g is not zero. Help them determine this number.

I was asked this problem in my Uber Phone Screen round and could not come up with the optimal answer. Can anyone provide a solution to this problem?

Comments