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:
Kartik Kapgate
2022-09-22 17:20:04 +05:30
committed by GitHub
parent c7f9bf961c
commit d05bbf77c6
3 changed files with 40 additions and 0 deletions

View 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)
})
})