Leetcode - Kth Smallest Number in Multiplication Table
Leetcode - Last Stone Weight II

Leetcode - First Unique Character in a String

violet posted @ May 06, 2020 01:29:06 AM in 算法 with tags Algorithm Golang count sort , 240 阅读

https://leetcode.com/problems/first-unique-character-in-a-string/

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.

 

func firstUniqChar(s string) int {
    count := make([]int, 26)
    for i := 0; i < len(s); i++ {
        count[s[i]-'a']++
    }
    for i := 0; i < len(s); i++ {
        if count[s[i]-'a'] == 1 {
            return i
        }
    }
    return -1
}
UK Board Model Paper 说:
Aug 16, 2022 07:36:14 PM

Uttarakhand Board Model Paper 2023 Class 7 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams

LIC Online Payment L 说:
Jan 24, 2023 06:14:43 PM

Life Insurance Corporation was established in 1956 and Is the oldest insurance company in India, and it has been providing millions of individuals with their variety of insurance schemes along with giving a good service to the business groups. LIC Online Payment Login To have a successful policy on your name, it is mandatory to make the LIC online premium payment or offline in time, and timely paying the installments of LIC will keep your policy active and that will be helpful in your emergency.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter