'c++ find similar string in map/vector

Is there a c ++ function that finds all string occurrences above the map / vector that differ by max in 1 (generally n) character?

Possibly some procedure that would not be time consuming, ie not to do, for example, to program cycles and comparators.



Solution 1:[1]

No. It can't be common algorithm because people have varying ideas depending on concrete needs how to quantify "similarity" or "difference". It can not be made canonical.

So they specify it clearly for their use-case and then write their own are_similar_enough(a, b) filter predicate or difference_of(a, b) function.

Then they extract the similar elements from their container with std::ranges::views::filter or similar hand-made algorithm. I suggest you do same and if you have technical problems then ask.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1