https://leetcode.com/explore/interview/card/top-interview-questions-easy/127/strings/881/
/**
* @param {string} s
* @return {number}
*/
var firstUniqChar = function (s) {
for (const i in s) {
const letter = s[i];
if (s.indexOf(letter) === s.lastIndexOf(letter)) return i;
}
return -1;
};
GitHub : https://github.com/developeSHG/Algorithm-LeetCode/tree/main/first-unique-character-in-a-string
'Coding Test > LeetCode' 카테고리의 다른 글
[LeetCode] Two Sum (0) | 2024.10.29 |
---|---|
[LeetCode] (Array) Lv Easy. Contains Duplicate (0) | 2023.02.06 |
[LeetCode] (Array) Lv Easy. Rotate Array (0) | 2023.01.31 |
[LeetCode] (Design) Lv Easy. Shuffle an Array (0) | 2023.01.25 |
[LeetCode] (Math) Lv Easy. Fizz Buzz (0) | 2023.01.22 |
댓글