package leetcode;

/**
 * https://leetcode.com/problems/find-peak-element/
 */
public class Problem162 {
    public int findPeakElement(int[] num) {
        return findPeakElement(num, num.length - 1, 0);
    }

    private int findPeakElement(int[] num, int left, int right) {
        if (right >= left) {
            return right;
        }
        int mid = (left + right) / 2;
        if (num[mid] < num[mid + 1]) {
            return findPeakElement(num, left, mid + 1);
        } else {
            return findPeakElement(num, mid, right);
        }
    }
}

@@ -138,16 +138,17 @@
 nt%5B%5D num
+s
 ) %7B%0A    
@@ -155,194 +155,94 @@
     
-return findPeakElement(num, num.length - 1,
+int left =
  0
-)
 ;%0A    
-%7D%0A%0A
     
-private int findPeakElement(int%5B%5D num, int left, int right) %7B%0A        if (right %3E= left) %7B%0A            return
+int right = nums.length - 1;%0A        while (left %3C
  right
-;
+) %7B
 %0A    
-    %7D%0A
     
@@ -287,15 +287,20 @@
     
+  
+  
 if (num
+s
 %5Bmid
@@ -306,16 +306,17 @@
 d%5D %3C num
+s
 %5Bmid + 1
@@ -336,49 +336,26 @@
     
-return findPeakElement(num,
+   
  left
-,
+ =
  mid + 1
 );%0A 
@@ -350,19 +350,22 @@
  mid + 1
-)
 ;%0A
+    
         
@@ -389,58 +389,69 @@
     
-return findPeakElement(num, mid, right);%0A        %7D
+    right = mid;%0A            %7D%0A        %7D%0A        return left;
 %0A   

Update problem 162