LeetCode-First Unique Character in a String
来源:互联网 发布:360数据恢复免费版 编辑:程序博客网 时间:2024/04/28 05:10
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist,
return -1.
return -1.
Examples:
Note: You may assume the string contain only lowercase letters.
题目含义:给一个字符串,找出字符串中第一个没有重复的字符,并返回他的索引,如果不存在则返回-1。可以假设字符串中只包含小写字母。
解题思路:由于题设字符串中只包含小写字母,所以可以建立一个26个元素的数组,统计字符串中各个字符出现的次数,然后再次遍历字符串,找到第一个出现次数只有1的元素,返回下标,若遍历完后未发现只出现1次的结果则返回-1.
1 0
- [Leetcode]First Unique Character in a String
- LeetCode: First Unique Character in a String
- LeetCode-First Unique Character in a String
- leetcode---First Unique Character in a String
- leetcode:First Unique Character in a String
- LeetCode-First Unique Character in a String
- [Leetcode] First Unique Character in a String
- leetcode First Unique Character in a String
- Leetcode First Unique Character in a String
- LEETCODE--First Unique Character in a String
- LeetCode -- First Unique Character in a String
- LeetCode : First Unique Character in a String
- LeetCode First Unique Character in a String
- LeetCode-----First Unique Character in a String
- LeetCode—387. First Unique Character in a String
- 【leetcode】387. First Unique Character in a String【E】
- LeetCode(387)First Unique Character in a String
- <LeetCode OJ> 387. First Unique Character in a String
- 【String】StringBuffer类的参数传递
- MySQL explain执行计划解读
- 六大设计原则之迪米特原则
- Linux 用户管理
- strcpy/strstr/strtok函数实现——菜鸟版
- LeetCode-First Unique Character in a String
- BOOST编译
- VS2012注册
- android之自定义动画
- 增长黑客
- Fiddler使用
- 开始博客之路
- 六种方式实现hibernate查询
- ViewTreeObserver