TheAlgorithms / Rust

All Algorithms implemented in Rust
MIT License
22.91k stars 2.24k forks source link

added floyd cycle detection algorithm #756

Closed tashviks closed 4 months ago

tashviks commented 5 months ago

Pull Request Title: Add Floyd's Cycle Detection algorithm implementation in Rust

Description:

This PR adds an implementation of Floyd's Cycle Detection algorithm in Rust. Floyd's Cycle Detection algorithm is used to find a duplicate number in an array of integers, ensuring optimal time complexity and space efficiency.

Details:

Implemented the find_duplicate_number function using Floyd's Cycle Detection algorithm. Handles edge cases such as empty arrays gracefully, returning None when no duplicate is found. Added comprehensive test cases to validate the correctness of the implementation.

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.05%. Comparing base (616b1fb) to head (37d5408).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #756 +/- ## ======================================= Coverage 95.05% 95.05% ======================================= Files 306 306 Lines 22718 22718 ======================================= Hits 21594 21594 Misses 1124 1124 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tashviks commented 4 months ago

Is there any problem with the pr format