Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions find-minimum-in-rotated-sorted-array/DaleSeo.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search
  • 설명: 배열이 회전된 정렬 상태에서 최소값을 찾기 위해 중간값과 끝 값을 비교하여 범위를 반씩 좁히는 이진 탐색 패턴을 사용한다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(log n) O(log n)
Space O(1) O(1)

피드백: 배열의 각 단계에서 중간값과 끝값을 비교해 증가 여부를 판단하고 탐색 구간을 절반으로 축소한다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// TC: O(log n)
// SC: O(1)
impl Solution {
pub fn find_min(nums: Vec<i32>) -> 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]
}
}
Loading