#-*- 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. Bug测试报告--俄罗斯方块--新蜂

    项目名:俄罗斯方块 组名:新蜂 测试者:韩媛媛(nice!团队) 用户需求规格说明书URL:http://www.cnblogs.com/Boxer1994/p/6084035.html 组长博客UR ...

  2. ralink网卡驱动的下载地址集合

    linuxMT7612U11/7/2014v3.0.0.1http://cdn-cw.mediatek.com/Downloads/linux/MT7612U_DPO_LinuxSTA_3.0.0.1 ...

  3. 显示刚刚添加的最后一条数据,access,选择语句,select

    显示刚刚添加的最后一条数据,access,选择语句,select select top 1  * from s1 order by id desc

  4. 实施费用也能DIY--走出软件作坊:三五个人十来条枪 如何成为开发正规军(九)[转]

    上次咱们讲完了开发费用的计算,很多人在后面跟帖在那里算费用. 有人说:你把程序员都不当人,94天,一天都不休息啊. 我想答曰:94天,是工作时间.不算双休日在里面.也就是说,实际的开发周期长度是94+ ...

  5. 使用javascript判断浏览器对css3的支持情况【译】

    Quick Tip: Detect CSS3 Support in Browsers with JavaScript Jeffrey Way on Nov 15th 2010  步骤 1 首先我们要确 ...

  6. shell 在文件名后面添加特定数据

    for a in `ls mo-*`;do mv ${a%:} ${a%:}-1;done

  7. UI优化

    进入正题,我们这一篇文章会提到为什么使用HierarchyViewer,怎么使用HierarchyViewer,后者内容会多一下. 为什么使用HierarchyViewer 不合理的布局会使我们的应用 ...

  8. iOS证书申请详细流程

    一.事前准备 1.1 准备苹果帐号 首先您需要有一个苹果的开发者帐号,一个mac系统.如果没有帐号可以打开申请加入苹果的开发者计划.如何申请网上有详细的介绍,在此不多做介绍. 如果您已经有了一个帐号, ...

  9. Linux计划任务,自动删除n天前的旧文件【转】

    转自:http://blog.csdn.net/jehoshaphat/article/details/51244237 转载地址:http://yaksayoo.blog.51cto.com/510 ...

  10. java.security.NoSuchAlgorithmException: DES KeyGenerator not available

    更改jre,点击项目build path-->configure build path-->libraries-->jre library system-->edit--> ...