• 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

61.9
/src/leetcode/strIndexOfStr/typescript.ts
1
// 28. 找出字符串中第一个匹配项的下标:https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/description/
2
// 输入:haystack = "sadbutsad", needle = "sad"
3
// 输出:0
4

5
export function strIndexOfStr (haystack: string, needle: string): number {
1✔
6
  let m = haystack.length
1✔
7
  let n = needle.length
1✔
8
  if (m < n) return -1
1!
9
  for (let i = 0; i <= m - n; i++) {
1✔
10
    let flag = true
1✔
11
    for (let j = 0; j < n; j++) {
1✔
12
      if (haystack[i + j] !== needle[j]) {
3!
13
        flag = false
×
14
        break
×
15
      }
×
16
    }
3✔
17
    if (flag) return i 
1✔
18
  }
1!
19
  return -1
×
20
}
×
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