add new solutions

This commit is contained in:
Yiyang Kang 2026-03-19 15:29:54 +09:00
parent f297e11859
commit 4720cbefc4
8 changed files with 290 additions and 0 deletions

View file

@ -0,0 +1,17 @@
// Package q852 implements a solution for https://leetcode.com/problems/peak-index-in-a-mountain-array/
package q852
func peakIndexInMountainArray(arr []int) int {
l, r := 0, len(arr)-1
for l < r {
m := (l + r) / 2
if arr[m] < arr[m+1] { // incrementing
l = m + 1
} else {
r = m
}
}
return l
}
var _ = peakIndexInMountainArray