TheAlgorithms / Rust

All Algorithms implemented in Rust
MIT License
21.51k stars 2.1k forks source link

added floyd cycle detection algorithm #756

Open tashviks opened 1 week ago

tashviks commented 1 week 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 1 week ago

Codecov Report

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

Project coverage is 95.04%. Comparing base (d30b5b5) to head (28f7c69).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #756 +/- ## ======================================= Coverage 95.04% 95.04% ======================================= Files 305 305 Lines 22677 22677 ======================================= Hits 21553 21553 Misses 1124 1124 ```

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

tashviks commented 3 days ago

Is there any problem with the pr format