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

Aberta
#775 0 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@ChenYingHan1121 já está trabalhando nisso.

Desde 19/11/2026.

  • #777 de @ChenYingHan1121 — aberto

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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.

Linguagem predominante
Rust
Estrelas
236
Forks
153
Merge médio
1d 9h
PRs com merge (30d)
187

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sysprog21/codetrial

Todas as issues de sysprog21/codetrial

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.