剑指offer 35 第一个只出现一次的字符
来源:互联网 发布:汉诺塔递归算法python 编辑:程序博客网 时间:2024/06/11 08:28
题目描述
在一个字符串(1<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置
思路
哈希,水题。
代码
# -*- coding:utf-8 -*-class Solution: def FirstNotRepeatingChar(self, s): # write code here char_dict = {} for c in s: if c in char_dict.keys(): char_dict[c] += 1 else: char_dict[c] = 1 for i, v in enumerate(s): if char_dict[v] == 1: return i return -1
阅读全文
0 0
- 剑指offer(35)第一个只出现一次的字符
- 剑指offer-35 第一个只出现一次的字符
- 剑指Offer 35 第一个只出现一次的字符
- 剑指offer 35 第一个只出现一次的字符
- 【剑指offer】第一个只出现一次的字符
- 剑指offer--第一个只出现一次的字符
- 剑指Offer之 - 第一个只出现一次的字符
- 《剑指offer》第一个只出现一次的字符位置
- 剑指offer:第一个只出现一次的字符位置
- 剑指Offer--第一个只出现一次的字符位置
- 【剑指Offer】第一个只出现一次的字符位置
- 【剑指offer】之第一个只出现一次的字符
- 剑指offer:第一个只出现一次的字符位置
- [剑指offer]第一个只出现一次的字符位置
- 《剑指offer》-第一个只出现一次的字符位置
- 剑指offer|第一个只出现一次的字符位置
- 剑指Offer:第一个只出现一次的字符
- 【剑指offer】第一个只出现一次的字符
- POJ-2823 && POJ-3250 (单调队列 && 单调栈)
- ORA-00845,momery_target not supported on this system
- APP交叉事件测试
- APP兼容测试点
- DBNULL和NULL的区别
- 剑指offer 35 第一个只出现一次的字符
- Ubuntu 16.04 TensorFlow Servering
- vue学习1
- HDU 5088 Revenge of Nim II 高斯消元(异或,矩阵秩)
- html标签转义和反转义
- AIDL的实例讲解
- Spark机器学习环境搭建
- String与int、long、float、double等相互转换
- 自定义省电模式