Spot Capacity Round Trips tests accept the two largest rising runs
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Beginne mit problem-bank/judges.json und suche die Fälle zu Spot Capacity Round Trips. Füge die gemeldete Eingabe [[1,2,4,2,5,7,2,4,9,0]] mit dem erwarteten Wert 13 hinzu und generiere anschließend die Judges wie angefordert neu. Erledigt ist die Aufgabe, wenn der hinzugefügte Fall die beschriebene falsche Lösung zurückweist, während eine korrekte Lösung weiterhin besteht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 228
- Forks
- 150
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 226
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 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
Diagnostic category comment disagrees with its testsEvtl. vergeben @woohsin hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
sysprog21/codetrial#666 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Local recording ends at Finish, before the learning reviewEvtl. vergeben @richard81115 hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
sysprog21/codetrial#663 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Task editor scroll-sync test fails intermittently in CIEvtl. vergeben @melonpuff hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
sysprog21/codetrial#654 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
sysprog21/codetrial#646 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in sysprog21/codetrial
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
C-Bug S-Needs-Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bevyengine/bevy#26536 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Component:Software Type:Cleanup
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
horizon-rust/horizon#16176 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag