본문 바로가기
LeetCode/Top Interview Q. - Easy

LeetCode 387. First Unique Character in a String

by 벤진[Benzene] 2020. 5. 25.

Problem:

Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.

 

Examples:

 

s = "leetcode" return 0.

s = "loveleetcode", return 2.

 

-Summary-

1. Create a dictionary to save each character count in 's'

2. Using for loop, if we find any index of character's count is 1, then we return the index value. 

   (After loop is done, if answer not found return -1)

 

모든 문제에 대한 저작권은 LeetCode 회사에 있습니다. [Copyright © 2020 LeetCode]

https://leetcode.com/

'LeetCode > Top Interview Q. - Easy' 카테고리의 다른 글

LeetCode. Valid Palindrome [String]  (0) 2020.06.01
LeetCode 242. Valid Anagram  (0) 2020.05.25
LeetCode 7. Reverse Integer  (0) 2020.05.25
LeetCode 350. Intersection of Two Arrays II  (0) 2020.05.24
LeetCode 136. Single Number  (0) 2020.05.23

댓글