Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
Maintainers usually reply within 1 day
@PeteChiang1211 is already working on this.
Since Nov 26, 2026.
Assessment
This issue has not been assessed yet.
Description
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.
- Dominant language
- Rust
- Stars
- 236
- Forks
- 153
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 187
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/codetrial
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Unify Java harness validation error messagesPossibly taken @weichieh0204 claimed this today. Open
sysprog21/codetrial#872 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Inferred void class operations are never checked against the starter's return typePossibly taken @papaya0112 claimed this today. Open
sysprog21/codetrial#871 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwritePossibly taken @BOBOGUAGUA428 claimed this today. Open
sysprog21/codetrial#869 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in sysprog21/codetrial
Similar issues
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#59692 ·
Maintainers usually reply within 1 day
-
Retire stale Python-parity labels in Rust ingress and auth testsPossibly taken @github-actions claimed this today. Openfactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
JoshCLWren/comic-pile#5874 · 2 comments ·
Maintainers usually reply within 1 day
-
status:ready unit
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nonagenticai/conveyor#787 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day