add: 只出现一次的数字等
This commit is contained in:
7
test/string/compare-strings.test.js
Normal file
7
test/string/compare-strings.test.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { compareStrings } from '../../src/string/compare-strings'
|
||||
|
||||
test('比较字符串', () => {
|
||||
expect(compareStrings('ABCD', 'AB')).toBe(true)
|
||||
expect(compareStrings('ABCD', 'ACD')).toBe(true)
|
||||
expect(compareStrings('ABCD', 'AABC')).toBe(false)
|
||||
})
|
7
test/string/contains-duplicate.test.js
Normal file
7
test/string/contains-duplicate.test.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { containsDuplicate } from '../../src/string/contains-duplicate'
|
||||
|
||||
test('存在重复元素', () => {
|
||||
expect(containsDuplicate([1, 2, 3, 1])).toBe(true)
|
||||
expect(containsDuplicate([1, 2, 3, 4])).toBe(false)
|
||||
expect(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])).toBe(true)
|
||||
})
|
9
test/string/count-binary-substrings.test.js
Normal file
9
test/string/count-binary-substrings.test.js
Normal file
File diff suppressed because one or more lines are too long
12
test/string/regular-expression-matching.test.js
Normal file
12
test/string/regular-expression-matching.test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import regularExpressionMatching from '../../src/string/regular-expression-matching'
|
||||
|
||||
test('regularExpressionMatching', () => {
|
||||
expect(regularExpressionMatching('aa', 'a')).toEqual(false)
|
||||
expect(regularExpressionMatching('aaa', 'aa')).toEqual(false)
|
||||
expect(regularExpressionMatching('aa', 'aa')).toEqual(true)
|
||||
expect(regularExpressionMatching('aa', 'a*')).toEqual(true)
|
||||
expect(regularExpressionMatching('ab', '.*')).toEqual(true)
|
||||
expect(regularExpressionMatching('aab', 'c*a*b')).toEqual(true)
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*p*.')).toEqual(false)
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*ip*.')).toEqual(true)
|
||||
})
|
8
test/string/repeated-substring-pattern.test.js
Normal file
8
test/string/repeated-substring-pattern.test.js
Normal file
@ -0,0 +1,8 @@
|
||||
import repeatedSubstringPattern from '../../src/string/repeated-substring-pattern'
|
||||
|
||||
test('repeatedSubstringPattern', () => {
|
||||
expect(repeatedSubstringPattern('abab')).toEqual(true)
|
||||
expect(repeatedSubstringPattern('ab')).toEqual(false)
|
||||
expect(repeatedSubstringPattern('aba')).toEqual(false)
|
||||
expect(repeatedSubstringPattern('abcabcabcabc')).toEqual(true)
|
||||
})
|
9
test/string/restore-ip-addresses.test.js
Normal file
9
test/string/restore-ip-addresses.test.js
Normal file
@ -0,0 +1,9 @@
|
||||
import restoreIpAddresses from '../../src/string/restore-ip-addresses'
|
||||
|
||||
test('恢复IP地址', () => {
|
||||
expect(restoreIpAddresses('25525511135')).toEqual(['255.255.11.135', '255.255.111.35'])
|
||||
expect(restoreIpAddresses('1116512311')).toEqual(['11.165.123.11', '111.65.123.11'])
|
||||
expect(restoreIpAddresses('00000')).toEqual([])
|
||||
expect(restoreIpAddresses('0000')).toEqual(['0.0.0.0'])
|
||||
expect(restoreIpAddresses('010010')).toEqual(['0.10.0.10', '0.100.1.0'])
|
||||
})
|
5
test/string/reverse-words-in-a-string.test.js
Normal file
5
test/string/reverse-words-in-a-string.test.js
Normal file
@ -0,0 +1,5 @@
|
||||
import ReverseWordsInAString from '../../src/string/reverse-words-in-a-string'
|
||||
|
||||
test('ReverseWordsInAString', () => {
|
||||
expect(ReverseWordsInAString('Let\'s take LeetCode contest')).toBe('s\'teL ekat edoCteeL tsetnoc')
|
||||
})
|
6
test/string/unique-characters.test.js
Normal file
6
test/string/unique-characters.test.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { isUnique } from '../../src/string/unique-characters'
|
||||
|
||||
test('判断字符串是否没有重复字符', () => {
|
||||
expect(isUnique('abc___')).toBe(false)
|
||||
expect(isUnique('abc')).toBe(true)
|
||||
})
|
Reference in New Issue
Block a user