From c4240d907d7f7ae4517f18e9f6fa7cf41f23af2c Mon Sep 17 00:00:00 2001 From: Dale Seo <5466341+DaleSeo@users.noreply.github.com> Date: Wed, 15 Jul 2026 21:23:40 -0400 Subject: [PATCH] find-minimum-in-rotated-sorted-array --- find-minimum-in-rotated-sorted-array/DaleSeo.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 find-minimum-in-rotated-sorted-array/DaleSeo.rs diff --git a/find-minimum-in-rotated-sorted-array/DaleSeo.rs b/find-minimum-in-rotated-sorted-array/DaleSeo.rs new file mode 100644 index 0000000000..f487aab29e --- /dev/null +++ b/find-minimum-in-rotated-sorted-array/DaleSeo.rs @@ -0,0 +1,16 @@ +// TC: O(log n) +// SC: O(1) +impl Solution { + pub fn find_min(nums: Vec) -> i32 { + let (mut lo, mut hi) = (0, nums.len() - 1); + while lo < hi { + let mid = (lo + hi) / 2; + if nums[mid] > nums[hi] { + lo = mid + 1; + } else { + hi = mid; + } + } + nums[lo] + } +}