/*
* @lc app=leetcode.cn id=2351 lang=typescript
*
* [2104] 第一个出现两次的字母
*/
// @lc code=start
function repeatedCharacter(s: string): string {}
// @lc code=end
function repeatedCharacter(s: string): string {
const set = new Set<string>()
for (let ch of s) {
if (set.has(ch)) return ch
set.add(ch)
}
return ''
}
test.each([
{ input: { s: 'abccbaacz' }, output: 'c' },
{ input: { s: 'abcdd' }, output: 'd' },
])('input: s = $input.s', ({ input: { s }, output }) => {
expect(repeatedCharacter(s)).toEqual(output)
})