Skip to content

Commit da20498

Browse files
Made changes according to PA
1 parent c1d00c3 commit da20498

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

dsa-solutions/lc-solutions/0000-0099/0033-search-in-rotated-sorted-array.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,52 @@
11
---
22
id: search-in-rotated-sorted-array
33
title: Search in Rotated Sorted Array (LeetCode)
4-
difficulty: Medium
54
sidebar_label: 0033-SearchInRotatedSortedArray
65
description: Search for a target element in a rotated sorted array with distinct values using an algorithm with O(log n) runtime complexity.
76
---
87

98
## Problem Description
109

11-
1210
| Problem Statement | Solution Link | LeetCode Profile |
1311
| :---------------- | :------------ | :--------------- |
1412
| [Merge Two Sorted Lists](https://leetcode.com/problems/search-in-rotated-sorted-array/) | [Merge Two Sorted Lists Solution on LeetCode](https://leetcode.com/problems/search-in-rotated-sorted-array/solutions/) | [VijayShankerSharma](https://leetcode.com/u/darkknight648/) |
1513

1614
## Problem Description
1715

18-
There is an integer array $nums$ sorted in ascending order (with distinct values).
16+
There is an integer array nums sorted in ascending order (with distinct values).
1917

20-
Prior to being passed to your function, $nums$ is possibly rotated at an unknown pivot index $k$ (0 <= k < nums.length) such that the resulting array is $[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]$ (0-indexed).
18+
Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed).
2119

22-
Given the array $nums$ after the possible rotation and an integer $target$, return the index of $target$ if it is in $nums, or -1 if it is not in $nums$.
20+
Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.
2321

2422
You must write an algorithm with $O(log n)$ runtime complexity.
2523

2624
### Examples
2725

2826
#### Example 1
2927

30-
- **Input:** $nums = [4,5,6,7,0,1,2]$, $target = 0$
31-
- **Output:** $4$
32-
- **Explanation:** 0 is located at index 4 in the rotated sorted array $[4,5,6,7,0,1,2]$.
28+
- **Input:** nums = [4,5,6,7,0,1,2], target = 0
29+
- **Output:** 4
30+
- **Explanation:** 0 is located at index 4 in the rotated sorted array [4,5,6,7,0,1,2].
3331

3432
#### Example 2
3533

36-
- **Input:** $nums = [4,5,6,7,0,1,2]$, $target = 3$
37-
- **Output:** $-1$
38-
- **Explanation:** 3 is not in $nums$, so return -1.
34+
- **Input:** nums = [4,5,6,7,0,1,2], target = 3
35+
- **Output:** -1
36+
- **Explanation:** 3 is not in nums, so return -1.
3937

4038
#### Example 3
4139

42-
- **Input:** $nums = [1]$, $target = 0$
43-
- **Output:** $-1$
44-
- **Explanation:** 0 is not in $nums$, so return -1.
40+
- **Input:** nums = [1], target = 0
41+
- **Output:** -1
42+
- **Explanation:** 0 is not in nums, so return -1.
4543

4644
### Constraints
4745

4846
- $v1 <= nums.length <= 5000$
4947
- $-10^4 <= nums[i] <= 10^4$
5048
- All values of $nums$ are unique.
51-
- $nums$ is an ascending array that is possibly rotated.
49+
- nums is an ascending array that is possibly rotated.
5250
- $-10^4 <= target <= 10^4$
5351

5452
### Approach

0 commit comments

Comments
 (0)