Skip to content

Commit 7928a3f

Browse files
committed
Add solution #81
1 parent b84ebc8 commit 7928a3f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
77|[Combinations](./0077-combinations.js)|Medium|
7777
78|[Subsets](./0078-subsets.js)|Medium|
7878
80|[Remove Duplicates from Sorted Array II](./0080-remove-duplicates-from-sorted-array-ii.js)|Medium|
79+
81|[Search in Rotated Sorted Array II](./0081-search-in-rotated-sorted-array-ii.js)|Medium|
7980
83|[Remove Duplicates from Sorted List](./0083-remove-duplicates-from-sorted-list.js)|Easy|
8081
86|[Partition List](./0086-partition-list.js)|Medium|
8182
88|[Merge Sorted Array](./0088-merge-sorted-array.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* 81. Search in Rotated Sorted Array II
3+
* https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
4+
* Difficulty: Medium
5+
*
6+
* There is an integer array nums sorted in non-decreasing order (not
7+
* necessarily with distinct values).
8+
*
9+
* Before being passed to your function, nums is rotated at an unknown
10+
* pivot index k (0 <= k < nums.length) such that the resulting array
11+
* is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]
12+
* (0-indexed). For example, [0,1,2,4,4,4,5,6,6,7] might be rotated at pivot
13+
* index 5 and become [4,5,6,6,7,0,1,2,4,4].
14+
*
15+
* Given the array nums after the rotation and an integer target, return
16+
* true if target is in nums, or false if it is not in nums.
17+
*
18+
* You must decrease the overall operation steps as much as possible.
19+
*/
20+
21+
/**
22+
* @param {number[]} nums
23+
* @param {number} target
24+
* @return {boolean}
25+
*/
26+
var search = function(nums, target) {
27+
return nums.includes(target);
28+
};

0 commit comments

Comments
 (0)