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

src/main/java/com/fishercoder/solutions/_162.java

Lines changed: 12 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy