Skip to content

Commit 8914c98

Browse files
author
hojas
committed
BinarySearch
1 parent 2a91840 commit 8914c98

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { binarySearch } from './binary-search'
3+
4+
describe('binarySearch', () => {
5+
it('should find the index of target in nums', () => {
6+
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
7+
const target = 7
8+
9+
const index = binarySearch(arr, target)
10+
expect(index).toBe(6)
11+
})
12+
})

0 commit comments

Comments
 (0)