美文网首页
Leetcode-Easy 852. Peak Index in

Leetcode-Easy 852. Peak Index in

作者: 致Great | 来源:发表于2018-08-15 16:25 被阅读9次

题目描述

给一个数据A,其中A中第i个元素满足A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1],要求找到i并返回

思路

A[i]为数组A的最大值,然后返回其在A中的索引即可

代码实现

class Solution:
    def peakIndexInMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: int
        """
        return A.index(max(A))          

相关文章

网友评论

      本文标题:Leetcode-Easy 852. Peak Index in

      本文链接:https://www.haomeiwen.com/subject/jcpwbftx.html