Sowndappan S 37b34c2bac perf(strings): optimize anagram signature using frequency counts (#12927)
* fix(strings): use frequency-based signature for anagrams

Replaced the sorting-based signature implementation with a frequency-based
approach using `collections.Counter`. This ensures that the signature
represents both characters and their counts, preventing collisions and
better grouping of true anagrams.

Examples:
- "test" → "e1s1t2"
- "finaltest" → "a1e1f1i1l1n1s1t2"
- "this is a test" → " 3a1e1h1i2s3t3"

Also updated the anagram lookup to use the new frequency-based signatures, making results more accurate and avoiding false positives.

* Refactor anagram function return type to list[str]

* Update anagrams.py

* Update anagrams.py

* Update anagrams.py

* Update anagrams.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-24 15:33:18 +03:00
2023-10-11 14:30:02 -04:00
2024-09-30 23:01:15 +02:00
2025-07-06 01:35:29 +03:00
2025-07-06 01:35:29 +03:00
2025-07-06 01:35:29 +03:00
2023-10-03 14:47:10 +05:30
2024-08-25 17:33:11 +02:00
2025-07-06 01:35:29 +03:00
2022-07-23 07:56:59 +05:30
2025-07-06 01:35:29 +03:00
2025-07-06 01:35:29 +03:00
2025-08-24 14:01:21 +03:00

The Algorithms - Python

Gitpod Ready-to-Code Contributions Welcome Discord chat Gitter chat
GitHub Workflow Status pre-commit code style: black

All algorithms implemented in Python - for education

Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion.

Getting Started

Read through our Contribution Guidelines before you contribute.

Community Channels

We are on Discord and Gitter! Community channels are a great way for you to ask questions and get help. Please join us!

List of Algorithms

See our directory for easier navigation and a better overview of the project.

Description
No description provided
Readme 20 MiB
Languages
Python 99.8%
Shell 0.2%