FirstUniqueCharIndex
约 104 字小于 1 分钟
2026-02-11
题目
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. (Inspired by leetcode 387)
解题思路
待补充
答案
type FirstUniqueCharIndex<T extends string> = any验证
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<FirstUniqueCharIndex<'leetcode'>, 0>>,
Expect<Equal<FirstUniqueCharIndex<'loveleetcode'>, 2>>,
Expect<Equal<FirstUniqueCharIndex<'aabb'>, -1>>,
Expect<Equal<FirstUniqueCharIndex<''>, -1>>,
Expect<Equal<FirstUniqueCharIndex<'aaa'>, -1>>,
]参考
无
