剑指offer 35. 第一次只出现一次的字符
来源:互联网 发布:移动硬盘修理软件 编辑:程序博客网 时间:2024/06/08 10:26
//题目:输入一个数组,找出第一个只出现一次的字符//使用辅助空间public class Main {public static void main(String[] args) throws Exception {System.out.println(findFirstChar("abaccdeff"));}public static char findFirstChar(String str){if(str == null){return ' ';}HashMap<Character, Integer> m = new HashMap<Character, Integer>();for(int i = 0;i<str.length();i++){char temp = str.charAt(i);int count = 1;if(m.containsKey(temp)){count = m.get(temp)+1;}m.put(temp, count);}for(int i = 0;i<str.length();i++){char temp = str.charAt(i);if(m.get(temp) == 1){return temp;}}System.out.println("not found");return ' ';}}
0 0
- 剑指offer 35. 第一次只出现一次的字符
- 剑指offer 35-第一次只出现一次的字符
- 剑指offer-第一次只出现一次的字符位置
- 剑指offer——第一次只出现一次的字符
- 《剑指offer》第一次只出现一次的字符
- 剑指offer--第一次只出现一次的字符
- 剑指offer:第一次只出现一次的字符
- 剑指offer——第一次只出现一次的字符
- 《剑指offer》:[35]第一次出现且只出现一次的字符
- 剑指offer之面试题35第一次只出现一次的字符
- 剑指offer——面试题35:第一次只出现一次的字符
- 剑指offer——34.第一次只出现一次的字符
- 剑指offer—字符串中第一次只出现一次的字符
- 第一次只出现一次的字符
- 第一次只出现一次的字符
- 查出第一次只出现一次的字符
- 第一次只出现一次的字符
- 第一次只出现一次的字符
- 玩家之旅2:新手入职
- 玩家之旅3:脚手架
- AVL旋转图解
- Git 常用命令图解
- Word第1、2页不显示页码,从第3页开始显示页码
- 剑指offer 35. 第一次只出现一次的字符
- SVN提交,强制注释
- html乱码原因与网页乱码解决方法
- JavaScript学习历程和心得体验
- 创业日志(十二) 关于怠惰
- 消息中间件-activemq实战之整合Spring(四)
- 内存泄露的原因
- JDBC总结
- 基于云计算和大数据的图书馆 应用系统建设设计