Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
Maintainer thường phản hồi trong vòng 1 ngày
@PeteChiang1211 đang làm issue này rồi.
Từ ngày 26/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
A solution that sorts the sites by offer and leases each one whose neighbours are still free passes all five house-robber cases, although it is not correct.
Wrong solution (Python):
class Solution:
def bestLeaseRevenue(self, nums):
taken, total = set(), 0
for i in sorted(range(len(nums)), key=lambda i: -nums[i]):
if i - 1 not in taken and i + 1 not in taken:
taken.add(i)
total += nums[i]
return total
It returns the right answer for every case in problem-bank/judges.json ([1, 2, 3, 1], [2, 7, 9, 3, 1], [5], [0, 0, 0], [2, 1, 1, 2]), because in each of them the largest offer belongs to an optimal set.
It fails when the largest offer sits between two smaller offers whose sum is bigger:
| nums | expected | greedy |
|---|---|---|
[2, 3, 2] |
4 | 3 |
[4, 5, 4, 1] |
8 | 6 |
Both inputs are inside the stated domain (1 to 100 sites, offers 0 to 400).
Proposed fix: add a case such as [2, 3, 2] (label along the lines of "largest offer is not in the best set") to the judge, and a test that pins the greedy solution to that case so removing the case fails the test, following the jump-game and stock III judge fixes. I would like to work on this.
- 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ự
-
bug bugfix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
storytold/photocraft#17140 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 70/100
-
bug command Java Edition protocol
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Pumpkin-MC/Pumpkin#4733 ·
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 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area:parity status:ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
neilsh/stunt-reel#1133 ·
Maintainer thường phản hồi trong vòng 1 ngày