Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- tensorflow
- Product Demand
- 코딩테스트
- 파이썬
- 피그마인디언
- Inventory Optimization
- ModelCheckPoint
- 코딩테스트연습
- 딥러닝
- oracle
- 당신의 인생이 왜 힘들지 않아야 한다고 생각하십니까
- 웨어하우스 보관 최적화
- Gaimification
- SKU Consolidation
- Labor Management System
- SQL
- kaggle
- eda
- forecast
- MS SQL Server
- MySQL
- leetcode
- pandas profiling
- 신경쓰기의 기술
- ProfileReport
- 프로그래머스
- HackerRank
- ABC Analysis
- TensorFlowGPU
- 데이터분석
Archives
- Today
- Total
오늘도 배운다
1204. Last Person to Fit in the Bus / LeetCode, SQL, MS SQL Server 본문
코딩테스트연습(SQL)
1204. Last Person to Fit in the Bus / LeetCode, SQL, MS SQL Server
LearnerToRunner 2023. 4. 15. 14:56문제
source: LeetCode
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 test cases are generated such that the first person does not exceed the weight limit.
제출답안(MS SQL Server)
WITH
queue_weight
AS (SELECT
*,
SUM(weight) OVER (ORDER BY turn) AS total_weight
FROM
queue)
SELECT
TOP 1 person_name
FROM
queue_weight
WHERE
total_weight <= 1000
ORDER BY
total_weight DESC
문제 바로가기(MS SQL Server)
728x90
'코딩테스트연습(SQL)' 카테고리의 다른 글
1934. Confirmation Rate / LeetCode, SQL, MS SQL Server (0) | 2023.04.17 |
---|---|
1321. Restaurant Growth / LeetCode, SQL, MS SQL Server (0) | 2023.04.16 |
550. Game Play Analysis IV / LeetCode, SQL, MS SQL Server (0) | 2023.04.14 |
1174. Immediate Food Delivery II / LeetCode, SQL, MySQL (0) | 2023.04.11 |
1193. Monthly Transactions I / LeetCode, SQL, MS SQL Server (0) | 2023.04.10 |
Comments