O75

Find Peak Element

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: NUMERIC

Problem Statement & Objective

A peak element is an element that is strictly greater than its neighbors. Find a peak element, and return its index in O(log n) time.

Function Signature (Python)

find_peak_element(nums: list[int]) -> int

Input & Output Contract

Output Rule:Herhangi bir geçerli zirve elemanın indeksi.

System Constraints

1 <= sayilar.length <= 10^5
-2^31 <= sayilar[i] <= 2^31 - 1
Komşu iki eleman asla birbirine eşit değildir (sayilar[i] != sayilar[i+1])

Example Execution Walkthrough

sayilar = [1, 2, 3, 1] -> 3 zirvedir -> indeks 2
sayilar = [1, 2, 1, 3, 5, 6, 4] -> indeks 1 (değer 2) veya indeks 5 (değer 6)

Example Test Scenarios (4)

Example 1
Input:[[1,2,3,1]]
Expected Output:2
Example 2: Single Element
Input:[[1]]
Expected Output:0
Example 3: Artan Dizi
Input:[[1,2]]
Expected Output:1
İki Zirve: 1 veya 5
Input:[[1,2,1,3,5,6,4]]
Expected Output:5
Loading Python Editor...
Input Parameters
[
  [
    1,
    2,
    3,
    1
  ]
]
Expected Output
2