Skip to content

Conversation

bivekk51
Copy link

@bivekk51 bivekk51 commented Oct 5, 2025

Description

  • Summary: Implemented search_rotated_sorted_array which finds a target in a rotated, ascending-sorted slice and returns Option<usize>.
  • Motivation: This algorithm complements existing searching implementations by handling arrays that were rotated after sorting.
  • Implementation method: A modified binary search that detects which half of the current range is normally ordered and narrows the search into the half that can contain the target. Assumes distinct elements.
  • Complexity: O(log n) time, O(1) extra space.
  • Notes: If duplicate elements must be supported, additional checks are required and worst-case complexity may degrade.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I ran below commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked CONTRIBUTING.md and my code follows its guidelines.

@bivekk51 bivekk51 requested a review from imp2002 as a code owner October 5, 2025 05:51
@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.34%. Comparing base (ed7a42e) to head (23b8eb8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #922      +/-   ##
==========================================
+ Coverage   95.32%   95.34%   +0.01%     
==========================================
  Files         319      320       +1     
  Lines       20899    20964      +65     
==========================================
+ Hits        19923    19988      +65     
  Misses        976      976              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants