We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc91e5d commit 991bc56Copy full SHA for 991bc56
README.md
@@ -515,4 +515,21 @@ FROM Accounts
515
UNION
516
SELECT 'High Salary' AS category, SUM(IF(income>50000,1,0)) AS accounts_count
517
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;
535
```
0 commit comments