Skip to content

Commit 10d2af4

Browse files
committed
Update 1095-find-in-mountain-array.cpp
Algorithm description removed
1 parent 3e0dd64 commit 10d2af4

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

Diff for: cpp/1095-find-in-mountain-array.cpp

+5-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
11
/**
2-
* Description:
3-
* (This problem is an interactive problem.)
4-
*
5-
* You may recall that an array arr is a mountain array if and only if:
6-
* arr.length >= 3
7-
* There exists some i with 0 < i < arr.length - 1 such that:
8-
* arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
9-
* arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
10-
*
11-
* Given a mountain array mountainArr, return the minimum index such that
12-
* mountainArr.get(index) == target. If such an index does not exist, return -1.
13-
*
14-
* You cannot access the mountain array directly. You may only access the array using
15-
* a MountainArray interface:
16-
* MountainArray.get(k) returns the element of the array at index k (0-indexed).
17-
* MountainArray.length() returns the length of the array.
18-
*
19-
* Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer.
20-
* Also, any solutions that attempt to circumvent the judge will result in disqualification.
21-
*
22-
* Ex1.
23-
* Input: array = [1,2,3,4,5,3,1], target = 3
24-
* Output: 2
25-
* Explanation: 3 exists in the array, at index=2 and index=5. Return the minimum index,
26-
* which is 2.
27-
*
28-
* Ex2.
29-
* Input: array = [0,1,2,4,2,1], target = 3
30-
* Output: -1
31-
* Explanation: 3 does not exist in the array, so we return -1.
322
*
333
* Algorithm:
34-
* 1. The algorithm's goal is to find the minimum index at which the value "target",
4+
* - The algorithm's goal is to find the minimum index at which the value "target",
355
* exist within a "MountainArray".
36-
* 2. It employs a binary search approach, dividing the array into ascending and
37-
* descending halves.Additionally, it identifies the peak index to determine the
6+
* - It employs a binary search approach, dividing the array into ascending and
7+
* descending halves. Additionally, it identifies the peak index to determine the
388
* transition from ascending to descending.
399
*
40-
* Time Complexity: O(log n)
10+
* Time Complexity: O(log n)
4111
* Space Complexity: O(1)
12+
*
4213
*/
4314

4415
/**

0 commit comments

Comments
 (0)