add: 只出现一次的数字等
This commit is contained in:
1 parent
930ff1be11
commit
8239e7afd5
106 files changed
+7978
No files matched your search
@@ -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)
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
import CountBinarySubstrings from '../../src/string/count-binary-substrings'
|
||||
|
||||
test('CountBinarySubstrings', () => {
|
||||
expect(CountBinarySubstrings('00110011')).toBe(6)
|
||||
})
|
||||
|
||||
test('CountBinarySubstrings2', () => {
|
||||
expect(CountBinarySubstrings('11001111101101100111111111111100110010111111111001101111111111010100100111100011111101111011111101011101000011110011100111010110001110111010111111101011001011111101011011011111110011111110000111101101011111111110101010011111000100000010011010011001011111101101111101111110100110011101111011100010111001100110100010111000000011010000111001111110101101011101100000111101101111010101100101011111010111111111111101001101011111011110011010111011111111111001110110110100101101111111011100110111111111100011101100001011111111111011100111110111000101111100111101111111101110001101010111011010111010110111000111011011111101110001111101011001101111110011111101111111011011100111011101111101111111010011111001110101110111100110111001011001010101100010111001101111011111101111111111100101011001001111101010111110101011011011111101111110110110010011110011110001110101111001001100111111111001001111000111110111000010011011110110111100101011100011110100000011111100010110001101101111110001100011101011001111111000111001010001110111011100111111111110111111011111100111101111011100111111011101111101111111011111010110101111101100110111011011111000010001010101101101110111111101111111001101110110011110111000110111001010101111111111011100101011010011110111101110111100110000001101111111111011110101100100101111111001111101110001011110101110111111111110000010111110111101111111111111001001000011011011111100100001111010011111111010110100111100110111110001110100000101100110110110111111111100111111011000101110110101110111111111101011101010011011000101111110011010110111110010001010111110111110111101101011111110110111101011110010101100011010110001101100111111011001111101001011110110010001111111101001111011001011111110101101100111100100101110101111111011111011111010011100111011111100011101110100110111011111000111111111010101011010111111111001101111001111011101100101101111000111110101100111111011011010001101100010100011110111001001111111110111110111111111001011110011111100110100100101111111101100010011011111100111110101100111011111101100100000011111110001101111011011110101111100010111000111110111001000001111110110110100101001101010110011111111011110101111110001011100010111110101101101111111111111011010111000001101010011110101101111000110111101001101111111111111111000110110111100110100111001111111111101101110011101001101110100101101111111111111111100011011110111111101110100011011101111101001111101111111101101111111110111110000001011011011110110111111111111110111110001011111111011111111111111111111111001001110000110100010001101101101111111101011110001101001000011110111001111110101001011010101000001110011111010110011111101110111110110101111110111110110101001110111100010000101111101101111101110110110100010101011011111111011111000100101111011000001101001011110101001111011101110111010011011011110011101111011011111010001101101101111011110110111010100011110100111111101110110111000011111111111110001110101010011100101000110110111011110101111100111110101011010101011111100101011110101110011100000111101000111101101111010011100111011101101011111110001011110101111101111100011111101001000011010100010111111100101101100001011111101101111010001011110111110110011000001111111111010100101001111001111101111000111111011110111111001111100001011110111010010011110011011101001001011011110011111111110001101111111010101100110100100110010001111000101001111110011011111100111110001111010111011111101011111011110101101111111011110111111111111000011011001101100111111111011111111010110100101101100111010001111011111101111110111111111101100111000011111100011110111001111111010111111101001100001100110010111110010011101110111101011011010110110110100111101110111001010110110011100010011010110101110000011010111111111010110011110010011000011111101010011111110111000001111001101010100101111011101110111110101101011111011001111111100110111010111011111100110001101110101100111111111111001110111011110111111011111100111010111001011001001111111111110110111001111111111001011111110011110101000110111110010000101111011111110111111001111101110101011111110111110110100001100101110110110001111110110100001110010101011111010111110101111000110010111101110111011100010001111111111001011001100110110111101111110001000101111110111101001110101111111110010111111111110011111101100100110011111001110111100111110001011011111001100110000101001101111011001111101111011110111111001100110111110110011010101111111110101111111001011010111111110111000011110110111111110111111100101001100000000110000101110111011111011111111011011110010111110101101101010111000011101001010011110011110111011010100110101101111011111101011011111001101111011111111010100001010100100011101110001101011011001011111011010111001011110111111011110111101000010111101101111111110110001111110011110101110110101110001011100110101100101111111011111111101110111110101101111110010101110011101101010110001111100000100011011111110000110101101111000101111100100011100111110011101010010001001110111100001001111011011110100111010110101011010000111111110111Line truncated
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
@@ -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'])
|
||||
})
|
||||
@@ -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')
|
||||
})
|
||||
@@ -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