Skip to content

Conversation

sgindeed
Copy link

@sgindeed sgindeed commented Oct 6, 2025

Description of Change

This pull request adds a new algorithm for checking if two strings are valid anagrams.

The implementation uses a hash table (std::unordered_map) to efficiently count and compare character frequencies. The file is self-contained and includes Doxygen-style documentation explaining the algorithm, along with a test() function to verify its correctness against various cases.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Adds a new, self-contained, and tested anagram checker algorithm.

}

// Use a hash map to store character frequencies.
std::unordered_map<char, int> counts;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think character frequency could be negative, use an unsigned integer here, fixed width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants