add: 最长公共前缀
This commit is contained in:
1 parent
581a96e795
commit
8ca4a189f8
4 files changed
+42
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import { longestCommonPrefix } from '../../src/string/longest-common-prefix'
|
||||
|
||||
test('最长公共前缀', () => {
|
||||
expect(longestCommonPrefix(['flower', 'flow', 'flight'])).toBe('fl')
|
||||
expect(longestCommonPrefix(['dog', 'racecar', 'car'])).toBe('')
|
||||
expect(longestCommonPrefix(['a'])).toBe('a')
|
||||
expect(longestCommonPrefix(['caa', '', 'a', 'acb'])).toBe('')
|
||||
})
|
||||
Reference in new issue
Block a user