Is Subsequence judge accepts frequency-only solutions that ignore character order

未关闭
#775 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@ChenYingHan1121 已经在做这个了。

开始于 2026年11月19日。

  • #777 来自 @ChenYingHan1121 —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

Problem

The is-subsequence judge does not currently test whether a solution preserves the relative order of characters.

As a result, an incorrect frequency-count implementation passes all five existing judge cases, even though it does not satisfy the problem statement.

Steps to Reproduce

The judge is defined in problem-bank/judges.json under is-subsequence.

I compared two implementations against the existing five cases:

  • Incorrect implementation: Counts character frequencies in t and checks whether all characters of s are available, ignoring order.

  • Correct implementation: Uses two pointers to match the characters of s in their original order within t.

Both implementations passed all five existing cases.

Implementation Existing cases passed
Frequency-count implementation (incorrect) 5/5
Two-pointer implementation (correct) 5/5

Minimal Counterexample

s = "ab"
t = "ba"

Expected result: false

Actual result from the incorrect frequency-count implementation: true

Both characters exist in t, but they appear in the wrong order. Therefore, s is not a subsequence of t.

The correct two-pointer implementation returns false.

Proposed Fix

Add an order-sensitive case to the is-subsequence judge:

{
  "label": "reversed character order",
  "input": ["ab", "ba"],
  "expected": false
}

This test rejects the frequency-count implementation while allowing the correct two-pointer implementation.

Verification

I reproduced the issue locally using the actual five cases loaded from problem-bank/judges.json.

Results:

  • Incorrect frequency-count solution: 5/5 existing cases passed.

  • Correct two-pointer solution: 5/5 existing cases passed.

  • Proposed reversed-order case: incorrect solution failed; correct solution passed.

The local reproduction directly compared outputs against the JSON judge cases. It did not execute the full browser runner.

No production-code changes are needed.

主要语言
Rust
星标
236
派生
153
平均合并
1 天 9 小时
30 天内合并 PR
187

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/codetrial 的其他 Issue

查看 sysprog21/codetrial 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。