Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
Los mantenedores suelen responder en 1 día
@PeteChiang1211 ya está trabajando en esto.
Desde el 26/11/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 236
- Forks
- 153
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 187
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sysprog21/codetrial
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Unify Java harness validation error messagesPosiblemente ocupada @weichieh0204 la tomó hoy. Abierto
sysprog21/codetrial#872 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Inferred void class operations are never checked against the starter's return typePosiblemente ocupada @papaya0112 la tomó hoy. Abierto
sysprog21/codetrial#871 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwritePosiblemente ocupada @BOBOGUAGUA428 la tomó hoy. Abierto
sysprog21/codetrial#869 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de sysprog21/codetrial
Issues similares
-
bug bugfix
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
storytold/photocraft#17140 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 70/100
-
bug command Java Edition protocol
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Pumpkin-MC/Pumpkin#4733 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
area:parity status:ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
neilsh/stunt-reel#1133 ·
Los mantenedores suelen responder en 1 día