Anonymizer Substitution Audit accepts distinct-count-only solutions

Open Beginner friendly
#879 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, rust
Domain
testing

Research direction

Find the built-in cases for Anonymizer Substitution Audit (LeetCode 205) and inspect how they are passed to the C++ runner. Add ["aab", "abb"] with expected result false, then confirm the existing cases still pass and that the distinct-count-only solution fails this case.

Written by the indexing model from the issue text.

Description

Observed behavior

Anonymizer Substitution Audit (isomorphic-strings, LeetCode 205) accepts a solution that only compares the number of distinct characters in the two strings:

#include <string>
#include <unordered_set>
using namespace std;

class Solution {
public:
    bool isConsistentCipher(string s, string t) {
        unordered_set<char> a(s.begin(), s.end());
        unordered_set<char> b(t.begin(), t.end());
        return a.size() == b.size();
    }
};

This solution passes all seven built-in cases. However, equal distinct-character counts do not establish a consistent one-to-one substitution.

For example:

s = "aab"
t = "abb"

Expected: false
Actual: true

The first occurrence of a would map to a, while the second would map to b, violating the problem's substitution rule.

All current false cases have different distinct-character counts, so they do not distinguish this shortcut from a correct implementation.

Expected behavior

The built-in cases should reject this solution by including a valid input with equal distinct-character counts but inconsistent character mappings, such as ["aab", "abb"], expecting false.
A correct two-way mapping solution should continue to pass every case.

Reproduction
  1. Open Anonymizer Substitution Audit and select C++.
  2. Replace the starter code with the solution above.
  3. Run the tests. All seven built-in cases pass.
CodeTrial version

codetrial 0.1.0 (9817ef6)

Environment

OS: Windows, x64
Browser: Microsoft Edge 157.0.4341.42 (headless verification)
Language: C++
Interview loop: N/A — direct browser-runner verification
Problem: Anonymizer Substitution Audit (LeetCode 205)
REACTO or STAR step: N/A
Reconnect: N/A

Sanitized evidence

Verified using the actual runBrowserTests implementation with language: "cpp" at the revision above:

Implementation Built-in cases Result for ["aab", "abb"]
Distinct-count-only C++ solution 7/7 true — incorrect
Correct two-way mapping C++ solution 7/7 false — correct

A separate counterexample check produced:

Input: ["aab", "abb"]
Expected: false
Got: true

The correct control uses mappings in both directions to enforce consistency and uniqueness.

Public data confirmation
  • I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
Dominant language
Rust
Stars
236
Forks
153
Avg merge
1d 9h
Merged PRs (30d)
187

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/codetrial

All issues in sysprog21/codetrial

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.