Submission Detail

66 / 66 test cases passed.
Status:

Accepted

Runtime: 0 ms
Memory Usage: 41.7 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

Sorry. We do not have enough accepted submissions to show distribution chart.

Accepted Solutions Memory Distribution

41400
40400
40600
40800
41000
41200
41600
41800
42000
42200
42400
2
4
6
8
10
java
You are here!
Your memory usage beats 35.43 % of java submissions.
Memory (KB)
Distribution (%)

41400
40400
40600
40800
41000
41200
41600
41800
42000
42200
42400
5
10
Zoom area by dragging across this chart

Invite friends to challenge Find Peak Element


Submitted Code: 0 minutes ago

Language: java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Solution {
public int findPeakElement(int[] nums) {
int mp = nums.length/2;
int ind = 0;
if (nums.length == 0)
return -1;
if (nums.length == 1)
return 0;
if (nums[mp-1] < nums[mp])
if (mp < nums.length-1)
if(nums[mp+1] < nums[mp])
return mp;
int[] left = new int[mp];
int[] right = new int[nums.length-mp-1];
for (int i = 0; i < mp; i++)
left[i] = nums[i];
for (int i = 0; i < nums.length-mp-1; i++)
right[i] = nums[mp+i+1];
if (left[left.length-1] > nums[mp]) {
ind = findPeakElement(left);
if (ind != -1)
return ind;
}
ind = findPeakElement(right);
return (mp + ind + 1);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX