1 parent 693752d commit ffb5084Copy full SHA for ffb5084
1 file changed
find_peak_element.py
@@ -0,0 +1,17 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+class Solution:
4
+ #@param A: An integers list.
5
+ #@return: return any of peek positions.
6
+ def findPeak(self, A):
7
+ # write your code here
8
+ ret = -1
9
+ for i in xrange(len(A)):
10
+ left = A[i - 1] if (i - 1) >= 0 else -2147483648
11
+ right = A[i + 1] if (i + 1) < len(A) else -2147483648
12
+ if A[i] > max(left, right):
13
+ if ret == -1:
14
+ ret = i
15
+ elif A[i] > A[ret]:
16
17
+ return ret
0 commit comments