• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fxss5201 / fxss-leetcode / 13761886410

10 Mar 2025 10:02AM UTC coverage: 96.505% (-0.2%) from 96.74%
13761886410

push

github

fxss5201
feat: add 81. 搜索旋转排序数组 II

1014 of 1091 branches covered (92.94%)

Branch coverage included in aggregate %.

54 of 60 new or added lines in 2 files covered. (90.0%)

3652 of 3744 relevant lines covered (97.54%)

6.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/leetcode/searchInRotatedSortedArrayIi/javascript.js
1
// 81. 搜索旋转排序数组 II:https://leetcode.cn/problems/search-in-rotated-sorted-array-ii/
1✔
2
// 输入:nums = [2,5,6,0,0,1,2], target = 0
1✔
3
// 输出:true
1✔
4

1✔
5
export function searchInRotatedSortedArrayIi (nums, target) {
1✔
6
  const n = nums.length
2✔
7
  if (n === 0) return false
2!
8
  if (n === 1) return nums[0] === target
2!
9
  let l = 0
2✔
10
  let r = n - 1
2✔
11
  while (l <= r) {
2✔
12
    const mid = Math.floor((l + r) / 2)
4✔
13
    if (nums[mid] === target) return true
4✔
14
    if (nums[l] === nums[mid] && nums[mid] === nums[r]) {
4✔
15
      l++
1✔
16
      r--
1✔
17
    } else if (nums[l] <= nums[mid]) {
4✔
18
      if (nums[l] <= target && target < nums[mid]) {
1✔
19
        r = mid - 1
1✔
20
      } else {
1!
NEW
21
        l = mid + 1
×
NEW
22
      }
×
23
    } else {
1✔
24
      if (nums[mid] < target && target <= nums[n - 1]) {
1!
NEW
25
        l = mid + 1
×
26
      } else {
1✔
27
        r = mid - 1
1✔
28
      }
1✔
29
    }
1✔
30
  }
4✔
31
  return false
1✔
32
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc