-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IsAnagram bug (per element counts) #153
Comments
related to #11 |
Thanks for supporting the development of C# Algorithms with your first issue! We look forward to handling it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The
IsAnagram
function is not checking per-element counts. It is only checking if they have the same elements, but not if the count of each element matches.A more appropriate name for the current logic is something like
ContainsNoDifferingElements
orIntersectsMatch
rather thanIsAnagram
. I would recommend changing the name or the logic of the method.To Reproduce
Add the following case to the
IsAnagram
unit tests:Expected behavior
Spans of the same length and elements but different per-element counts should not be considered re-orders/anagrams of each other.
Environment:
master branch
Additional context
I have written my own version of this algorithm in C# (that fixes this issue) if interested here...
The text was updated successfully, but these errors were encountered: