You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- There is a queue of people waiting to board a bus. However, the bus has a weight limit of 1000 kilograms, so there may be some people who cannot board.
-- Write an SQL query to find the person_name of the last person that can fit on the bus without exceeding the weight limit.
-- The testcases are generated such that the first person does not exceed the weight limit.
WITH cumulative_sum as (
SELECT *, SUM(weight) OVER(ORDER BY turn) as total_weight