Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
Maintainer antworten meist innerhalb von 1 Tag
@PeteChiang1211 arbeitet bereits daran.
Seit 26.11.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 236
- Forks
- 153
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 187
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus sysprog21/codetrial
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Unify Java harness validation error messagesEvtl. vergeben @weichieh0204 hat das heute übernommen. Offen
sysprog21/codetrial#872 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Inferred void class operations are never checked against the starter's return typeEvtl. vergeben @papaya0112 hat das heute übernommen. Offen
sysprog21/codetrial#871 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwriteEvtl. vergeben @BOBOGUAGUA428 hat das heute übernommen. Offen
sysprog21/codetrial#869 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in sysprog21/codetrial
Ähnliche Issues
-
bug bugfix
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
storytold/photocraft#17140 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
bug command Java Edition protocol
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Pumpkin-MC/Pumpkin#4733 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 2 Tagen
-
area:parity status:ready-for-agent
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
neilsh/stunt-reel#1133 ·
Maintainer antworten meist innerhalb von 1 Tag