TheAlgorithms / C-Plus-Plus

Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
https://thealgorithms.github.io/C-Plus-Plus
MIT License
30.67k stars 7.27k forks source link

feat: add duval's algorithm #2725

Closed aminegh20 closed 4 weeks ago

aminegh20 commented 1 month ago

Description of Change

Added the implementation of Duval's Algorithm for finding the lexicographically smallest cyclic shift of a sequence. The algorithm is based on the concept of Lyndon words and works in O(n) time, making it efficient for this type of task. This implementation is generic and works with various sequence types, such as strings, vectors, arrays, and deques.

Checklist