본문 바로가기
Coding Test/LeetCode

[LeetCode] (Strings) Lv Easy. First Unique Character in a String

by song.ift 2023. 2. 6.

https://leetcode.com/explore/interview/card/top-interview-questions-easy/127/strings/881/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com

 

/**
 * @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

 

GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드

릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.

github.com

 

댓글