题目:https://leetcode.com/problems/first-unique-character-in-a-string/

难度:Easy

int firstUniqChar(char* s) {int a[26][2]={0};for(int i=0;i<strlen(s);i++){a[s[i]-'a'][0]++;a[s[i]-'a'][1]=i;}int res= 100000;for(int i=0;i<26;i++){if(a[i][0]==1 && a[i][1]<res){res=a[i][1];}}if(res == 100000)return -1;return res;
}

  

转载于:https://www.cnblogs.com/boucher/p/5805584.html

LeetCode 387:first-unique-character-in-a-string相关推荐

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

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

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

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

  4. python leetcode 387. First Unique Character in a String

    利用find函数能极大地减少运行时间 class Solution:def firstUniqChar(self, s):""":type s: str:rtype: i ...

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

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

  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. C#LeetCode刷题之#387-字符串中的第一个唯一字符(First Unique Character in a String)

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

  8. Rust LeetCode 练习:929 Unique Email Addresses

    LeetCode 929 Unique Email Addresses 题目大意:邮箱地址格式为[本地名]@[域名],其中[本地名]存在+和.两种特殊情况.现在输入一组邮箱地址,要求进行如下处理,然后 ...

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

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

最新文章

  1. 继AutoML后,第四范式发布软硬一体化AI集成系统SageOne
  2. 06- 本地方法接口
  3. android通过Jni加载so库遇到UnsatisfiedLinkError问题!!!
  4. 使JavaDoc保持最新状态的工具
  5. [css] 当拿到一个新的项目,让你对这个项目的css做下架构设计,你该如何下手?
  6. 第17章分布式爬虫-17-1 分布式系统简介
  7. java 3d文字旋转_3d多物体点旋转
  8. 优化理论19----DNRTR无约束优化的对角拟牛顿修正方法
  9. 日期格式 java_Java时间日期格式转换
  10. 【应用随机过程】01. 随机过程的基本概念
  11. bt服务器搭建 linux_linux系统架设BT服务器的详细教程
  12. 春运抢火车票攻略汇总(持续更新中)
  13. Suspending console(s) (use no_console_suspend to debug) android4.0 OMAP4460
  14. 从打字机效果的 N 种实现看JS定时器机制和前端动画
  15. Ubuntu下插入网线无法联网的问题
  16. 服务器能共享性能吗,共享云服务器性能
  17. 智能对话系统:Unit对话API
  18. SSH git初次克隆代码问题报错 fatal: unable to update url base from redirection:
  19. 如何解决mac拔掉耗电量太大的设备以重新启用usb设备
  20. uebs游戏_UEBS Ultimate Epic Battle电脑版

热门文章

  1. 售票统计表表格模板_财务常用四大报表模板,共二十张,会计小白入职有它被高看一眼...
  2. washer和shell有什么区别_disk or washer method?
  3. 基于hadoop构建对象存储系统_基于Hadoop企业私有云存储平台的构建
  4. load data infile mysql_mysql Load Data InFile 的用法举例
  5. Linux内核参数优化网络带宽,基于Linux内核的网络带宽管理
  6. python中的pylab_Python数值计算:一 使用Pylab绘图(1)
  7. 的列数 获取mysql_阿里面试:MySQL如何设计索引更高效?
  8. 男孩子初中毕业学计算机技术,男孩子初中毕业学什么技术好就业
  9. 随机生成元素升序向量_使用random_shuffle()算法随机化序列元素
  10. 如何使基于梯度下降的机器学习并行化