Spot Capacity Round Trips tests accept the two largest rising runs
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
まず problem-bank/judges.json から始め、Spot Capacity Round Trips のケースを探してください。報告された入力 [[1,2,4,2,5,7,2,4,9,0]] と期待値 13 を追加し、依頼どおりに judges を再生成してください。追加したケースが説明されている誤った解法を不合格にし、正しい解法は引き続き合格することが完了の条件です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 228
- フォーク
- 150
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 226
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/codetrial のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Diagnostic category comment disagrees with its tests対応中かも @woohsin が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
sysprog21/codetrial#666 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Local recording ends at Finish, before the learning review対応中かも @richard81115 が 2 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
sysprog21/codetrial#663 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Task editor scroll-sync test fails intermittently in CI対応中かも @melonpuff が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sysprog21/codetrial#654 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
sysprog21/codetrial#646 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
sysprog21/codetrial の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
asonnino/blockchain-validator#88 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
storytold/photocraft#14025 ·
メンテナーはふだん 1 日以内に返信
-
Extrudeオープンarea:kernel bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bherbruck/solvecraft#16273 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
storytold/vectorcraft#7242 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信