#-*- 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. 三层与MVC

    三层架构(3-tier architecture) 我们平时总是将三层架构与MVC混为一谈,殊不知它俩并不是一个概念.下面我来为大家揭晓我所知道的一些真相. 首先,它俩根本不是一个概念. 三层架构是一 ...

  2. JSP-02- 使用JSP实现输出

    二. 使用JSP实现输出 JSP的页面构成: 静态内容.指令.表达式.Scriptlet.声明.动作.注释 Jsp脚本: 表达式.Scriptlet.声明 表达式: <%=  内容  %> ...

  3. 再次尝试mtk线刷时发现的一些资源

    线刷用到的工具:spflashtool,也可以下载vcom drivers 下载:http://spflashtool.com/ 查看usb状态的软件:usbdeview,网站里还有一些其它的软件 下 ...

  4. UBoot讲解和实践-----------讲解(一)

    Boot Loader之ARM Uboot移植 阶段一 理论篇 1.boot loader需要完成的任务:               1>设计程序的入口地址               2&g ...

  5. 最长上升子序列O(nlogn)算法详解

    最长上升子序列 时间限制: 10 Sec   内存限制:128 MB 题目描述 给定一个序列,初始为空.现在我们将1到N的数字插入到序列中,每次将一个数字插入到一个特定的位置.我们想知道此时最长上升子 ...

  6. 想学习一下CSS函数

    好像原来都是用前后端代码实现的功能,如今CSS3已经吸纳为标准,使用简单的选择器就可以实现了.

  7. iOS - 代码查看控制台打印内存使用情况:

    1.先导入: #import <mach/mach.h> 2.写此方法.单位为兆(M). void report_memory(void) { struct task_basic_info ...

  8. FTPS加密上传

    公司要求ftp接口不能以明文方式传输,所以adc系统将增加ftps方式 但是在网找了很多方式都无法实现用了方法一 FtpWebRequest request = (FtpWebRequest)WebR ...

  9. 删除 SQL Server 2005 Express 工具

    安装sql server 2008 management,提示错误:Sql2005SsmsExpressFacet 检查是否安装了 SQL Server 2005 Express 工具. 失败,已安装 ...

  10. mysql同步

    已安装好mysql,并且已把配置文件复制在/etc/my.cnf 主服务器的配置: 1,查看二进制日志的状态,开启二进制日志 进入mysql安装目录 #cd /usr/local/mysql 进入my ...