387、字符串中的第一个唯一字符(First Unique Character in a String) 题目: 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 示例: **提示:**你可以假定该字符串只包含小写字母。 解答: 法一: 法二: 387、字符串中的第一个唯一字符 题目: 给定一个字符串,找到它...
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. Note: You may assume the string contain only lowercase letters. 给一个字符串,找出第一个不重复的...
classSolution {publicintfirstUniqChar(String s) {if(s==null||s.length()==0){return-1; }int[] map =newint[26];//for(inti = 0; i<s.length(); i++){inta = map[(int)s.charAt(i)-97]; a++; map[(int)s.charAt(i)-97] =a; }for(inti = 0; i<s.length(); i++){if(...
【摘要】 1、题目 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 ... 1、题目 Given a string, find the first non-repeating character in it and retur...
题目: 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" return0. s="loveleetcode", return2. 题解: 扫两遍string. 第一遍s.chatAt(i)的对应count++. 第二遍找第一个count为1的char, return其in...
leetcode 387. 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....
LeetCode 387: 字符串中的第一个唯一字符 First Unique Character in a String 题目: 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1....
Description: 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. 1. 2. 3. 4. 5. 题意:给定一个字符串,返回字符串中第一个在字符串中只出现过一...
字符串中的第一个唯一字符 题目描述:给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。示例说明请见LeetCode官网。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/first-unique-character-in-a-string/著作权归领扣网络所有。商业转载请联系官方授权,非商业...
leetcode 每日一题:387. 字符串中的第一个唯一字符:https://leetcode-cn.com/problems/first-unique-character-in-a-string/ 一起刷题吧 一、题目分析 输入:字符串输出:第一个不重复的元素的下标难度:简单标签:哈希表,字符串 示例:s = "leetcode"返回0 ...