Skip to content

Commit 991bc56

Browse files
committed
Update README.md
1 parent cc91e5d commit 991bc56

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,21 @@ FROM Accounts
515515
UNION
516516
SELECT 'High Salary' AS category, SUM(IF(income>50000,1,0)) AS accounts_count
517517
FROM Accounts
518+
```
519+
520+
[1204. Last Person to Fit in the Bus](https://leetcode.com/problems/last-person-to-fit-in-the-bus/)
521+
```sql
522+
-- 1000 kg limit
523+
-- name of last person
524+
525+
WITH CTE AS (
526+
SELECT person_name, weight, turn, SUM(weight)
527+
OVER(ORDER BY turn) AS total_weight
528+
FROM Queue
529+
)
530+
SELECT person_name
531+
FROM cte
532+
WHERE total_weight <=1000
533+
ORDER BY total_weight DESC
534+
LIMIT 1;
518535
```

0 commit comments

Comments
 (0)