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

Ouverte
#775 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@ChenYingHan1121 y travaille déjà.

Depuis le 19/11/2026.

  • #777 par @ChenYingHan1121 — ouverte

Évaluation

Cette issue n'a pas encore été évaluée.

Description

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.

Langage dominant
Rust
Étoiles
236
Forks
153
Merge moyen
1 j 9 h
PR mergées (30 j)
187

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de sysprog21/codetrial

Toutes les issues de sysprog21/codetrial

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.