Solución
solution.tsTypeScript
export function findPeakElement(nums: number[]): number {
let max = Math.max(...nums)
for(let i = 0; i<nums.length; i++){
const left = i === 0 ? -Infinity : nums[i - 1];
const right = i === nums.length - 1 ? -Infinity : nums[i + 1];
if(nums[i] > left && nums[i] > right)
if (max > left && max > right) return nums.indexOf(max)
else return i
}
return 0;
}0respuestas