利用find函数能极大地减少运行时间

class Solution:def firstUniqChar(self, s):""":type s: str:rtype: int"""c='qwertyuiopasdfghjklzxcvbnm'res=2**31-1for n in c:index = s.find(n)if index ==-1:continueif s[index+1:].find(n)==-1:res=min(res,index)return res if res!=2**31-1 else -1

python leetcode 387. First Unique Character in a String相关推荐

  1. LeetCode: 387. First Unique Character in a String

    051105 题目 Given a string, find the first non-repeating character in it and return it's index. If it ...

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

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

    leetcode:https://leetcode-cn.com/problems/first-unique-character-in-a-string/ 387. 字符串中的第一个唯一字符 给定一个 ...

  4. 387. First Unique Character in a String QuestionEditorial Solution

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...

  5. LeetCode之First Unique Character in a String

    1.题目 Given a string, find the first non-repeating character in it and return it's index. If it doesn ...

  6. 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 ...

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

    目录 题目描述: 示例: 解法: 题目描述: 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引.如果不存在,则返回 -1. 示例: s = "leetcode"返回 0. ...

  8. C#LeetCode刷题之#387-字符串中的第一个唯一字符(First Unique Character in a String)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3939 访问. 给定一个字符串,找到它的第一个不重复的字符,并返回 ...

  9. 【LeetCode】467. Unique Substrings in Wraparound String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/unique-s ...

最新文章

  1. 动态规划走楼梯_动态规划问题为什么要画表格?
  2. js中字符串转为对象或者json
  3. [bzoj1187][HNOI2007]神奇游乐园
  4. php配置cors跨域漏洞怎么修复,CORS跨域漏洞的简单认识
  5. php和js序列化,PHP中serialize和json序列化与反序列化的区别
  6. pyspark对应的scala代码PythonRDD类
  7. [二进制拆分]Luogu1833 樱花
  8. macbook Intel版本安装anaconda和配置镜像源
  9. 搜狗输入法linux设置快捷键设置,搜狗输入法怎么创建桌面快捷键方式?
  10. 什么是知识库,怎么制作知识库?
  11. 域名申请攻略(以godaddy+支付宝为例)
  12. java timeunit_java并发之TimeUnit
  13. HTML5网页文本内容
  14. win10计算机无法识别u盘,win10电脑无法识别U盘应该如何解决
  15. 二进制文件漏洞挖掘 IDA插件VulFi安装使用
  16. iOS企业版app部署到自己的服务器
  17. 【windows】设置远程桌面连接?多用户登录设置?取消登录密码
  18. 电脑监控软件可以监控到企业微信吗?
  19. 大一C语言图形界面点餐系统
  20. android 4.0 更换鼠标图案

热门文章

  1. 光明勇士服务器一直维护中,光明勇士一人双职业利弊分析 到底好还是不好
  2. Python常用配置文件ini、json、yaml及python字典读写总结
  3. 程控电源CANoe上位机面板(CAN\ETH测试、RS232串口通信、编写设计思路)
  4. 31-最大子矩阵(蓝桥杯)
  5. 2020 NOC 编程猫创新编程全国决赛小学组第一部分(客观题)
  6. RatingBar基本使用
  7. 【Linux】将用户添加到root组中
  8. Spark数据分析之第4课
  9. 404错误的处理方式及对SEO的影响(更新)
  10. 山科大数字高程模型(朱红春版)复习 2021