You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Incorrect test case (Output of test case is incorrect as per the problem statement)
Bug Description
Test Case passing for Incorrect Peak.
Given Array = [1,10,2000,1,4,5,8,9,10]
The Peak is 2000, but Test Case accepting answer for 10 (8th Index)
Language Used for Code
Java
Code used for Submit/Run operation
class Solution {
public int findPeakElement(int[] arr) {
int start = 0;
int end = arr.length - 1;while (start < end) {
int mid = start + (end - start) / 2;if (arr[mid] > arr[mid+1]) {
end = mid;
} else {
// you are in asc part of array
start = mid + 1; // because we know that mid+1 element > mid element
}
}
return start;
}
}
Expected behavior
The Peak should be 2000, not 10
Screenshots
Additional context
No response
The text was updated successfully, but these errors were encountered:
LeetCode Support commented: Hello Kesavan Ramalingam,
Thank you for reaching out regarding the issue you're facing with the "Find Peak Element" problem. After reviewing the problem statement, it appears that the function's behavior aligns with the requirements. The problem states that you may return the index of any peak element. Since your test case [1,10,2000,1,4,5,8,9,10] has multiple peaks (including both 2000 and 10), the function's return value of the index of 10 is valid according to the problem's rules.
I recommend revisiting the problem statement to ensure full alignment with its requirements. If you have any further questions or need more clarification, please don't hesitate to reach out.
LeetCode Username
Kesavan Ramalingam
Problem Number, Title, and Link
Bug Category
Incorrect test case (Output of test case is incorrect as per the problem statement)
Bug Description
Test Case passing for Incorrect Peak.
Given Array = [1,10,2000,1,4,5,8,9,10]
The Peak is 2000, but Test Case accepting answer for 10 (8th Index)
Language Used for Code
Java
Code used for Submit/Run operation
Expected behavior
The Peak should be 2000, not 10
Screenshots
Additional context
No response
The text was updated successfully, but these errors were encountered: