First Letter to Appear Twice

EasyHash TableStringBit ManipulationCounting

Solution

export function repeatedCharacter(s: string): string {
  const set = new Set();
  for (const char of s) {
    if (set.has(char)) {
      return char;
    }
    set.add(char);
  }
  return '';
}