【leetcode】387. First Unique Character in a String 首个单字符
2016-09-20 15:28
375 查看
int firstUniqChar(char* s) { int len=strlen(s); int abc[26]={0}; int i=0; while (i<len){ abc[s[i]-'a']++; i++; } i=0; while (i<len){ if (abc[s[i]-'a']==1){ return i; } i++; } return -1; }
http://blog.csdn.net/vlin_hao/article/details/52596431
同样也是用字母表存出字母频数。
第一次写的时候,比较笨,没有想到可以利用i来传递下标,所以在字母表数组里存下标,过程比较麻烦。
相关文章推荐
- [LeetCode] Repeated String Match 重复字符串匹配
- leetcode_423. Reconstruct Original Digits from English ASCII码转换成字符,无序的英文字符对应的数字
- 联系人根据名字的首个字符拼音分组(支持非法字符)
- 首个重复字符(map的用法)----去哪儿2015研发工程师笔试题
- LeetCode | Scramble String(字符交换)
- [LeetCode] 451. Sort Characters By Frequency 根据字符出现频率排序
- [LeetCode] Wildcard Matching 字符串匹配,kmp,回溯,dp
- 首个字符重复
- LeetCode 604. Design Compressed String Iterator (设计压缩字符迭代器)$
- LeetCode number387 字符串第一个没有相同的字符
- [LeetCode] 1-bit and 2-bit Characters 一位和两位字符
- leetcode——Longest Substring Without Repeating Characters 求链表中无重复字符的最大字串长度(AC)
- leetcode----1位和2位字符问题
- leetcode Longest Substring Without Repeating Characters 没有重复字符的最长子字符串
- LeetCode_28---Implement strStr() [KMP算法,字符匹配算法]
- LeetCode 358. Rearrange String k Distance Apart(字符间隔)
- leetcode_345. Reverse Vowels of a String 转换字符串中的元音字符,list类型数据转换成str类型,join()函数
- LeetCode 8. String to Integer (atoi) C++ --字符串转为数字,包含正负号、空格、字母、数字等字符
- LeetCode-3:Longest Substring Without Repeating Characters (最长无重复字符的子串) --medium
- [去哪儿网]首个重复字符