Spot Capacity Round Trips tests accept the two largest rising runs
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
Direção de pesquisa
Comece por problem-bank/judges.json e encontre os casos de Spot Capacity Round Trips. Adicione a entrada reportada [[1,2,4,2,5,7,2,4,9,0]] com o valor esperado 13 e, em seguida, gere novamente os judges conforme solicitado. A tarefa estará concluída quando o caso adicionado rejeitar a solução incorreta descrita, enquanto uma solução correta continuar passando.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Observed behavior
In Spot Capacity Round Trips (best-time-to-buy-and-sell-stock-iii, LeetCode 123), the built-in tests accept a solution that splits the prices into rising runs and adds the two largest run gains. It passes 6/6, the same as a correct solution.
class Solution {
public:
int bestTwoRoundTrips(vector<int>& prices) {
vector<int> gains;
int n = prices.size(), i = 0;
while (i < n - 1) {
int j = i;
while (j + 1 < n && prices[j + 1] >= prices[j]) j++;
if (prices[j] > prices[i]) gains.push_back(prices[j] - prices[i]);
i = j > i ? j + 1 : i + 1;
}
sort(gains.rbegin(), gains.rend());
int total = 0;
for (int k = 0; k < (int)gains.size() && k < 2; k++) total += gains[k];
return total;
}
};
It never joins two runs into one trade across a dip. On [1,2,4,2,5,7,2,4,9,0] the runs gain 3, 5 and 7, so it returns 12. The answer is 13: buy at 1 and sell at 7, then buy at 2 and sell at 9. Every built-in case has at most two rising runs, or its best pair of trades is already two whole runs, so the tests cannot tell the two apart. The same solution written in Python also passes all 6 and returns 12 on the case above, since every language runs the same judge cases.
Expected behavior
At least one built-in case has three or more rising runs where the best two trades span a dip, so this solution fails the tests. A correct solution still passes every case.
Reproduction
- Run CodeTrial at the revision below and open Spot Capacity Round Trips with C++.
- Paste the solution above and run the tests. All 6 built-in cases pass.
- Under "Add a case", enter
[[1,2,4,2,5,7,2,4,9,0]]as the input and13as the expected value, then run again. The new case fails withgot 12.
CodeTrial version
codetrial 0.1.0 (c54aed7), built from source. The judge for this problem is unchanged between c54aed7 and main at d0544857.
Environment
- OS: Windows 11 with the server in WSL2
- Browser: Chrome 157.0.8103.51
- Language: C++
- Interview loop: Coding
- Problem: Spot Capacity Round Trips (LeetCode 123)
- REACTO or STAR step: Test
- Reconnect: None
Sanitized evidence
All 6 built-in cases pass, and the added case fails with got 12:
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
I would like to fix this by adding that case to problem-bank/judges.json and regenerating the judges. Please assign it to me.
- Linguagem predominante
- Rust
- Estrelas
- 228
- Forks
- 150
- Merge médio
- 1d 3h
- PRs com merge (30d)
- 226
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sysprog21/codetrial
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Diagnostic category comment disagrees with its testsTalvez já em andamento @woohsin assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
sysprog21/codetrial#666 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Local recording ends at Finish, before the learning reviewTalvez já em andamento @richard81115 assumiu há 2 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 84/100
sysprog21/codetrial#663 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Task editor scroll-sync test fails intermittently in CITalvez já em andamento @melonpuff assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
sysprog21/codetrial#654 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
sysprog21/codetrial#646 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de sysprog21/codetrial
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
C-Bug S-Needs-Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
bevyengine/bevy#26536 ·
Mantenedores costumam responder em até 2 dias
-
Component:Software Type:Cleanup
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Soul sand and honey slow a gliding or flying player; vanilla's Player.getBlockSpeedFactor is 1.0 thenTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
horizon-rust/horizon#16176 · 1 comentário ·
Mantenedores costumam responder em até 1 dia