An app keeps its last few log timestamps in a ring buffer, log. The timestamps were written in increasing order and the buffer wrapped around, so log is a sorted list rotated by some amount. All timestamps are different.
The oldest entry is the smallest timestamp. Write oldestIndex(log) that returns its index, in O(log n) time.
Input: log = [50,60,70,10,20,30,40] Output: 3
The values drop from 70 to 10, so the oldest is at index 3.
Input: log = [10,20,30] Output: 0
No wrap at all: the first entry is the oldest.
1 <= log.length <= 100000log is a sorted array rotated by some amount (possibly 0).Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #167 Oldest Entry in a Ring Log. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.