Skip to content

Commit f507110

Browse files
committed
#33: update description
1 parent 25063f2 commit f507110

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

c-sharp/Problems/binary-search/SearchInRotatedSortedArray.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,34 @@
33
* Search in Rotated Sorted Array
44
**
55
* There is an integer array nums sorted in ascending order (with distinct values).
6-
*
7-
* Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length)
8-
* such that the resulting array is
9-
* [nums[k], nums[k+1], ..., nums[n-1],
10-
* nums[0], nums[1], ..., nums[k-1]] (0-indexed).
11-
*
6+
* Prior to being passed to your function,
7+
* nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length)
8+
* such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed).
129
* For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].
1310
*
1411
* Given the array nums after the possible rotation and an integer target,
1512
* return the index of target if it is in nums, or -1 if it is not in nums.
1613
*
1714
* You must write an algorithm with O(log n) runtime complexity.
15+
*
16+
* Example 1:
17+
* Input: nums = [4,5,6,7,0,1,2], target = 0
18+
* Output: 4
19+
*
20+
* Example 2:
21+
* Input: nums = [4,5,6,7,0,1,2], target = 3
22+
* Output: -1
23+
*
24+
* Example 3:
25+
* Input: nums = [1], target = 0
26+
* Output: -1
27+
*
28+
* Constraints:
29+
* • 1 <= nums.length <= 5000
30+
* • -10^4 <= nums[i] <= 10^4
31+
* • All values of nums are unique.
32+
* • nums is an ascending array that is possibly rotated.
33+
* • -10^4 <= target <= 10^4
1834
**
1935
* https://leetcode.com/problems/search-in-rotated-sorted-array/
2036
***/

0 commit comments

Comments
 (0)