Problem "Maintenance Window Consolidation" accepts a solution that merges only one neighbouring pair
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
The fix is a new test case in the merge-intervals entry of problem-bank/judges.json, then regenerating the judge files with scripts/gen-problems.py as docs/adding-a-problem.md describes. Check that web/judges/maintenance-window-consolidation.json picks up the chained case [[1,3],[2,5],[4,8]] expecting [[1,8]]. Done when the buggy sort-merge-one-pair solution fails in a browser test and a correct sort-and-extend solution still passes all cases.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Observed behavior
In Maintenance Window Consolidation (ormerge-intervals, LeetCode 56), no built-in case needs a merged window to absorb a third one. A solution that sorts the windows, merges a window with only the next one and then skips past both therefore passes 5/5, the same as a correct solution.
class Solution:
def consolidateWindows(self, intervals: list[list[int]]) -> list[list[int]]:
intervals = sorted(intervals); out = []; i = 0
while i < len(intervals):
s, e = intervals[i]
if i + 1 < len(intervals) and intervals[i+1][0] <= e:
e = max(e, intervals[i+1][1]); i += 2
else:
i += 1
out.append([s, e])
return out
After merging a pair it never compares the extended window with the window that follows, so a chain of three overlapping windows comes back as two. On [[1,3],[2,5],[4,8]] it merges [1,3] and [2,5] into [1,5], then starts again at [4,8], and returns [[1,5],[4,8]] instead of [[1,8]]. That input is valid: problem-bank/problems.json allows 1 <= intervals.length <= 10^4 and 0 <= start_i <= end_i <= 10^4, and the contract in problem-bank/variants.json asks for "the union of the input [start, end] windows as non-overlapping [start, end] pairs".
Expected behavior
The built-in cases include a chain of three windows that merge into one, such as [[1,3],[2,5],[4,8]] expecting [[1,8]], so the solution above fails the tests. A correct solution still passes every case.
Reproduction
- Start CodeTrial and open Maintenance Window Consolidation with Python 3 selected.
- Paste the solution above into the editor and click Run tests: all five built-in cases pass.
- Under Add a case, add
[[1,3],[2,5],[4,8]]expecting[[1,8]]and run the tests again: that case fails withgot [[1,5],[4,8]].
The same result outside the browser: at upstream main 7023a392, calling the solution on each case in web/judges/maintenance-window-consolidation.json and comparing with expected passes 5/5, as does a correct sort-and-extend solution; on [[1,3],[2,5],[4,8]] the correct one returns [[1,8]].
CodeTrial version
codetrial 0.1.0 (7023a39)
Environment
OS: Windows 11 Version 26H2
Browser: Chrome 157.0.8103.79 (64-bit)
Language: Python
Sanitized evidence
The run on the interview page: the five built-in cases pass and the added chained case fails with expected [[1,8]], got [[1,5],[4,8]].
The solution above and a correct one, run against the five cases in web/judges/maintenance-window-consolidation.json at 7023a392, plus the proposed case:
| Solution | Existing cases | [[1,3],[2,5],[4,8]] (expecting answer[[1,8]]) |
|---|---|---|
| Sort, then extend the current window while the next one overlaps (correct) | 5/5 | [[1,8]] |
| Sort, merge one neighbouring pair, skip both (above) | 5/5 | [[1,5],[4,8]] |
I would like to fix this by adding the case to the merge-intervals entry in problem-bank/judges.json, regenerating the judges with python3 scripts/gen-problems.py as docs/adding-a-problem.md describes, and adding a browser test that names the solution the new case rejects.
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
- Ngôn ngữ chính
- Rust
- Star
- 236
- Fork
- 153
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 187
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sysprog21/codetrial
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Unify Java harness validation error messagesCó thể đã có người làm @weichieh0204 đã nhận hôm nay. Đang mở
sysprog21/codetrial#872 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Inferred void class operations are never checked against the starter's return typeCó thể đã có người làm @papaya0112 đã nhận hôm nay. Đang mở
sysprog21/codetrial#871 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwriteCó thể đã có người làm @BOBOGUAGUA428 đã nhận hôm nay. Đang mở
sysprog21/codetrial#869 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sysprog21/codetrial
Issue tương tự
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
manaflow-ai/cmux#59692 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Retire stale Python-parity labels in Rust ingress and auth testsCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởfactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
JoshCLWren/comic-pile#5874 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status:ready unit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
nonagenticai/conveyor#787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày