Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
I maintainer di solito rispondono entro 1 giorno
@PeteChiang1211 ci sta già lavorando.
Dal 26/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 236
- Fork
- 153
- Merge medio
- 1g 9h
- PR unite (30g)
- 187
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sysprog21/codetrial
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Unify Java harness validation error messagesForse già presa @weichieh0204 l’ha presa oggi. Aperta
sysprog21/codetrial#872 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Inferred void class operations are never checked against the starter's return typeForse già presa @papaya0112 l’ha presa oggi. Aperta
sysprog21/codetrial#871 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwriteForse già presa @BOBOGUAGUA428 l’ha presa oggi. Aperta
sysprog21/codetrial#869 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sysprog21/codetrial
Issue simili
-
bug bugfix
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
storytold/photocraft#17140 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 70/100
-
bug command Java Edition protocol
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Pumpkin-MC/Pumpkin#4733 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
area:parity status:ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
neilsh/stunt-reel#1133 ·
I maintainer di solito rispondono entro 1 giorno