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

fxss5201 / fxss-leetcode / 14559966275

20 Apr 2025 01:30PM CUT coverage: 96.345% (-0.04%) from 96.385%
14559966275

push

github

fxss5201
feat: 增加 14. 第一个元素、18. 获取元组长度、43. 实现 Exclude

1014 of 1091 branches covered (92.94%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

3652 of 3752 relevant lines covered (97.33%)

6.17 hits per line

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

67.74
/src/leetcode/searchInRotatedSortedArray/typescript.ts
1
// 33. 搜索旋转排序数组:https://leetcode.cn/problems/search-in-rotated-sorted-array/description/
2
// 输入:nums = [4,5,6,7,0,1,2], target = 0
3
// 输出:4
4

5
export function searchInRotatedSortedArray (nums: number[], target: number): number {
1✔
6
  let low = 0
1✔
7
  let high = nums.length - 1
1✔
8
  while (low <= high) {
1✔
9
    let mid = low + Math.floor((high - low) / 2)
3✔
10
    if (nums[mid] === target) {
3✔
11
      return mid
1✔
12
    }
1✔
13
    if (nums[low] <= nums[mid]) {
2✔
14
      if (nums[low] <= target && target < nums[mid]) {
2✔
15
        high = mid - 1
1✔
16
      } else {
1✔
17
        low = mid + 1
1✔
18
      }
1✔
19
    } else {
3!
20
      if (nums[mid] < target && target <= nums[high]) {
×
21
        low = mid + 1
×
22
      } else {
×
23
        high = mid - 1
×
24
      }
×
25
    }
×
26
  }
3!
27
  return -1
×
28
}
×
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

© 2025 Coveralls, Inc