Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2 ).
Find the minimum element.
The array may contain duplicates.
<Solution>這題是 Find Minimum in Rotated Sorted Array 的衍生題
不難,只改動一個地方
因為現在會有重複的值出現,所以判斷是從 if(nums.front() > nums.back())
變成 if(nums.front() >= nums.back())
code 如下
c++
kotlin
沒有留言:
張貼留言