PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000095. Vị trí đỉnh của dãy hình núi (Peak Index in a Mountain Array)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Vị trí đỉnh của dãy hình núi (Peak Index in a Mountain Array)
Peak Index in a Mountain Array
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
A mountain array strictly increases to a unique interior peak index , then strictly decreases. Return the zero-based peak index.
Input
The first line contains ; the second contains the mountain-array values.
Output
Print the peak index .
Subtasks
- Subtask 1 (20 points): ; ; the sequence strictly rises to an interior peak and strictly falls afterward.
- Subtask 2 (30 points): ; ; the sequence strictly rises to an interior peak and strictly falls afterward.
- Subtask 3 (50 points): ; ; the sequence strictly rises to an interior peak and strictly falls afterward.
Examples
Input
4
0 10 5 2
Output
1
Explanation
The sequence rises from to and then falls through . The peak is at index .