Skip to content

153-find-minimum-in-rotated-sorted-array#2

Open
05ryt31 wants to merge 1 commit intomainfrom
feat/153
Open

153-find-minimum-in-rotated-sorted-array#2
05ryt31 wants to merge 1 commit intomainfrom
feat/153

Conversation

@05ryt31
Copy link
Owner

@05ryt31 05ryt31 commented Dec 1, 2025

問題リンク

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/description/

問題文の概要

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

[4,5,6,7,0,1,2] if it was rotated 4 times.
[0,1,2,4,5,6,7] if it was rotated 7 times.
Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].

Given the sorted rotated array nums of unique elements, return the minimum element of this array.

You must write an algorithm that runs in O(log n) time.

次に解く予定の問題

33 search-in-rotated-array
https://leetcode.com/problems/search-in-rotated-sorted-array/description/

while left < right:
mid = (left + right) // 2

if nums[mid] < nums[right]:
Copy link

Choose a reason for hiding this comment

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

念のため確認させてください。 nums[right] の代わりに nums[0] と比較することで、同じような処理を書くことはできますか?また、 nums[-1] と比較することで、同じような処理を書くことはできますか?

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