#-*- coding: UTF-8 -*-
class Solution(object):
    def firstUniqChar(self, s):
        s=s.lower()
        sList=list(s)
        numCdic={}
        for c in s:
            numCdic[c]=numCdic[c]+1 if c in numCdic else 1
        for i in range(len(sList)):
            if numCdic[sList[i]]==1:
                return i
 
        return -1
    
sol=Solution()
print sol.firstUniqChar('loveleetcode')

【leetcode❤python】387. First Unique Character in a String的更多相关文章

  1. [LeetCode&Python] Problem 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 ex ...

  2. 【LeetCode】387. First Unique Character in a String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  3. 【LeetCode】387. First Unique Character in a String

    Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/first-unique-cha ...

  4. 【leetcode❤python】 438. Find All Anagrams in a String

    class Solution(object):    def findAnagrams(self, s, p):        """        :type s: s ...

  5. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

  6. LeetCode 387. First Unique Character in a String (字符串中的第一个唯一字符)

    题目标签:String, HashMap 题目给了我们一个 string,让我们找出 第一个 唯一的 char. 设立一个 hashmap,把 char 当作 key,char 的index 当作va ...

  7. [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 ex ...

  8. LeetCode 387. First Unique Character in a String

    Problem: Given a string, find the first non-repeating character in it and return it's index. If it d ...

  9. 【leetcode❤python】 1. Two Sum

    #-*- coding: UTF-8 -*- #AC源码[意外惊喜,还以为会超时]class Solution(object):    def twoSum(self, nums, target):  ...

随机推荐

  1. 夺命雷公狗ThinkPHP项目之----企业网站17之网站配置页的添加

    为了网站可以智能一点,所以我们开始来写一个网站配置的功能.. 所以我来写他的数据表: 先来完成他的添加功能,页面效果如下所示: lists.html代码如下所示: <!doctype html& ...

  2. RobotFrameWork接口报文测试-----(三)demo的加强版(数据驱动测试)

    在上一篇RobotFrameWork接口报文测试-----(二)demo的升级版基础上,将接口的xml的格式保存在xml文件中,然后程序如果增加一个接口,在xml文件里添加即可,无需修改自动化测试里的 ...

  3. 设置Sql Agent运行Job时的执行账户

    相信使用过Sql Server的人都应该知道,使用Sql Agent可以建立一些自动化Job来帮我们周期性地执行一些任务,其中执行SSIS包就是其中一个任务.而在SSIS包中有时候会去做读取文件等一些 ...

  4. android 开发工具(android studio)

      Android Studio 从安装到配置使用 okhttp比xutils功能强大,源码地址: https://github.com/search?utf8=✓&q=okhttp andr ...

  5. 匹配 prev 元素之后的所有 siblings 元素

    描述: 找到所有与表单同辈的 input 元素 HTML 代码: <form> <label>Name:</label> <input name=" ...

  6. Error while trying to retrieve text for error ORA-01019 的解决办法

    这个问题涉及到 64 位的oracle服务, 和32位的客户端导致的问题. 环境如下: win8.1 + 64位oracle 11.1 做服务器, 客户端由于采用32位程序,不支持64位的oracle ...

  7. Java总结第一次//有些图片未显示,文章包含基础java语言及各种语句

    一.java入门 1.Java入门学习框架: 2.常用的DOS命令: dir(directory) :    列出当前目录下的文件以及文件夹 md(make directory) :   创建目录 r ...

  8. linux 使用串口连接设备console

    linux使用串口连接cisco设备的console   linux 自带一个串口命令:minicom,需要经过设置,之后就可以连接了.   传说是默认就可以,我可能RP不好,我必须要经过设置才可以. ...

  9. android 开发中的常见问题

    Android studio 使用极光推送, 显示获取sdk版本失败 在 build.gradle(Module.app) 添加 android {    sourceSets.main {      ...

  10. linux配置java环境变量(详细)【转】

    转自:http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux ...