Find Maximum in Rotated Sorted Array - aloalgo

Find Maximum in Rotated Sorted Array

Hard

You are given a rotated array of unique integers, originally sorted in ascending order.

Your task is to find the largest element in the array.

You may assume that:

  • The array contains no duplicate elements.

Return the largest element found.

Example 1

Input
[4, 5, 6, 7, 0, 1, 2]
Output
7
Explanation:

The array is [4, 5, 6, 7, 0, 1, 2]. The largest element is 7.

Example 2

Input
[11, 13, 15, 17]
Output
17
Explanation:

The array is [11, 13, 15, 17]. This is equivalent to an array rotated 0 times. The largest element is 17.

Example 3

Input
[5, 1, 2, 3, 4]
Output
5
Explanation:

The array is [5, 1, 2, 3, 4]. The largest element is 5.

Loading...
Input
[4, 5, 6, 7, 0, 1, 2]
Output
7

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!