Spot Capacity Round Trips tests accept the two largest rising runs
维护者通常 1 天内回复
评估
调研方向
从 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 小时
- 30 天内合并 PR
- 226
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 85/100
storytold/vectorcraft#7242 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复