add: 和可被K整除的子数组

This commit is contained in:
2020-05-27 06:39:13 +08:00
parent 6098f48863
commit 596ae26ade
13 changed files with 26 additions and 0 deletions

View File

@ -1,6 +0,0 @@
import { waysToChange } from '../../src/math/coin-lcci'
test('硬币', () => {
expect(waysToChange(5)).toBe(2)
expect(waysToChange(10)).toBe(4)
})

View File

@ -1,6 +0,0 @@
import trailingZeroes from '../../src/math/factorial-trailing-zeroes'
test('trailingZeroes', () => {
expect(trailingZeroes(3)).toBe(0)
expect(trailingZeroes(5)).toBe(1)
})

View File

@ -1,8 +0,0 @@
import { maximum } from '../../src/math/maximum-lcci'
test('最大数值', () => {
expect(maximum(1, 2)).toBe(2)
expect(maximum(108, 133)).toBe(133)
expect(maximum(199, 133)).toBe(199)
expect(maximum(2147483647, -2147483648)).toBe(2147483647)
})

View File

@ -1,7 +0,0 @@
import { findMedianSortedArrays } from '../../src/math/median-of-two-sorted-arrays'
test('寻找两个正序数组的中位数', () => {
expect(findMedianSortedArrays([], [1])).toBe(1.0)
expect(findMedianSortedArrays([1, 3], [2])).toBe(2.0)
expect(findMedianSortedArrays([1, 2], [3, 4])).toBe(2.5)
})

View File

@ -1,9 +0,0 @@
import { isPalindrome } from '../../src/math/palindrome-number'
test('回文数', () => {
expect(isPalindrome(121)).toBe(true)
expect(isPalindrome(0)).toBe(true)
expect(isPalindrome(11)).toBe(true)
expect(isPalindrome(10)).toBe(false)
expect(isPalindrome(-121)).toBe(false)
})

View File

@ -1,6 +0,0 @@
import { checkPerfectNumber } from '../../src/math/perfect-number'
test('完美数', () => {
expect(checkPerfectNumber(28)).toBe(true)
expect(checkPerfectNumber(2)).toBe(false)
})

View File

@ -1,12 +0,0 @@
import { permute } from '../../src/math/permutations'
test('全排列', () => {
expect(permute([1, 2, 3])).toEqual([
[1, 2, 3],
[1, 3, 2],
[2, 1, 3],
[2, 3, 1],
[3, 1, 2],
[3, 2, 1]
])
})

View File

@ -1,7 +0,0 @@
import { myPow } from '../../src/math/powx-n'
test('Pow(x, n)', () => {
expect(myPow(2.00000, 10)).toBe('1024.00000')
expect(myPow(2.10000, 3)).toBe('9.26100')
expect(myPow(2.00000, -2)).toBe('0.25000')
})

View File

@ -1,5 +0,0 @@
import { subarraySum } from '../../src/math/subarray-sum-equals-k'
test('和为K的子数组', () => {
expect(subarraySum([1, 1, 1], 2)).toBe(2)
})

View File

@ -1,7 +0,0 @@
import { nthUglyNumber } from '../../src/math/ugly-number-ii.js'
test('丑数 II', () => {
expect(nthUglyNumber(9)).toBe(10)
expect(nthUglyNumber(1)).toBe(1)
expect(nthUglyNumber(10)).toBe(12)
})