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

Aperta
#775 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ChenYingHan1121 ci sta già lavorando.

Dal 19/11/2026.

  • #777 di @ChenYingHan1121 — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Rust
Stelle
236
Fork
153
Merge medio
1g 9h
PR unite (30g)
187

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sysprog21/codetrial

Tutte le issue di sysprog21/codetrial

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.