Is Subsequence judge accepts frequency-only solutions that ignore character order
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
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
tand checks whether all characters ofsare available, ignoring order.Correct implementation: Uses two pointers to match the characters of
sin their original order withint.
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.
- Dominant language
- Rust
- Stars
- 236
- Forks
- 153
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 187
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/codetrial
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Unify Java harness validation error messagesPossibly taken @weichieh0204 claimed this today. Open
sysprog21/codetrial#872 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Inferred void class operations are never checked against the starter's return typePossibly taken @papaya0112 claimed this today. Open
sysprog21/codetrial#871 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwritePossibly taken @BOBOGUAGUA428 claimed this today. Open
sysprog21/codetrial#869 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in sysprog21/codetrial
Similar issues
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eliasstravik/herdr-projects#1605 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
jlcodes99/cockpit-tools#3332 ·
Maintainers usually reply within 3 days
-
Cognito: the email MFA code (EMAIL_OTP challenge after a password flow) has 8 digits; AWS delivers 6Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-emulator#692 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 82/100
pamburus/hl#1779 · 1 comment ·
Maintainers usually reply within 1 day