Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 454 Bytes

File metadata and controls

26 lines (20 loc) · 454 Bytes

First letter to appear twice

Problem link

Solutions

Solution.cpp

// https://leetcode.com/problems/first-letter-to-appear-twice

class Solution {
 public:
  char repeatedCharacter(string s) {
    set<char> ss;
    for (char c : s) {
      if (ss.count(c)) return c;
      ss.insert(c);
    }
    return ' ';
  }
};

Tags