Skip to content

Commit 5292c3a

Browse files
update 162 with examples
1 parent c8e1297 commit 5292c3a

File tree

1 file changed

+12
-1
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+12
-1
lines changed

Diff for: src/main/java/com/fishercoder/solutions/_162.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ public static class Solution1 {
77
* credit: https://leetcode.com/problems/find-peak-element/solutions/1290642/intuition-behind-conditions-complete-explanation-diagram-binary-search/
88
* Time: O(logn)
99
* <p>
10-
* draw three cases with three examples, it's pretty self-explanatory
10+
* draw three cases with three examples, it's pretty self-explanatory:
11+
* case 1:
12+
* mid
13+
* 1, 3, 2
14+
* case 2:
15+
* mid
16+
* 1, 2, 3
17+
* so peak should be on the right side, so code is: left = mid + 1
18+
* case 3:
19+
* mid
20+
* 3, 2, 1
21+
* so peak should be on the left side, so code is: right = mid - 1;
1122
*/
1223
public int findPeakElement(int[] nums) {
1324
if (nums == null || nums.length <= 1 || nums[0] > nums[1]) {

0 commit comments

Comments
 (0)