[Leetcode] 387. First Unique Character in a String


Problem

leetcode Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1.

Solution

  • 주어진 문자열에서 반복하지않은 문자를 반환 없으면 -1을 리턴
  • Sol1
    • 주어진문자열의 {문자:개수}를 가지는 dictionary를 구현
    • 주어진 문자열의 반복하여 개수가 1인 문자를 처음 발견 시 리턴

Code