add: 有序矩阵中第K小的元素

This commit is contained in:
2020-07-02 11:36:45 +08:00
parent 16ec46e003
commit 89d8ac5e58
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import { kthSmallest } from '../../src/array/kth-smallest-element-in-a-sorted-matrix.js'
test('有序矩阵中第K小的元素', () => {
expect(kthSmallest([
[1, 5, 9],
[10, 11, 13],
[12, 13, 15]
], 8)).toBe(13)
expect(kthSmallest([
[1, 5, 7],
[3, 7, 8],
[4, 8, 9]
], 4)).toBe(5)
expect(kthSmallest([
[1, 2],
[3, 4]
], 3)).toBe(3)
})