mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-08 12:35:16 +08:00
algorithm: first unique char in a string (#1103)
* feat: Added Algo first unique char in a string. * Optimised algo to linear time complexity * removed double quotes * Review changes: if-else logic
This commit is contained in:
9
String/test/FirstUniqueCharacter.test.js
Normal file
9
String/test/FirstUniqueCharacter.test.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { firstUniqChar } from '../FirstUniqueCharacter'
|
||||
|
||||
describe('firstUniqChar', () => {
|
||||
it('locates the index of first unique character in the string', () => {
|
||||
expect(firstUniqChar('javascript')).toEqual(0)
|
||||
expect(firstUniqChar('sesquipedalian')).toEqual(3)
|
||||
expect(firstUniqChar('aabb')).toEqual(-1)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user