Skip to content

Bug Report for is-anagram wrong code segment passes test cases #5819

@SiddharthSri0

Description

@SiddharthSri0

Bug Report for https://neetcode.io/problems/is-anagram

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

This code segment

class Solution {
public:
bool isAnagram(string s, string t) {
unordered_set us;
unordered_set us1;
for(auto x : s){
if(us.count(x))
continue;
else
us.insert(x);
}
for(auto x : t){
if(us1.count(x))
continue;
else
us1.insert(x);
}
return us==us1;
}
};
passes all the test cases but this shuold return wrong because strings of type aab and abb are not anagram but this is not included in testing that is why this code segment passes all the test cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions