剑指Offer-35
来源:互联网 发布:淘宝旺铺版本区别 编辑:程序博客网 时间:2024/06/06 13:23
题目:
在字符串中找出第一个只出现一次的字符。
实现
// coding = javapublic class Solution35 { public static void findChar(String str){ if(str==null || str.length()<1){ return; } Map<Character,Integer> dic = new HashMap<Character,Integer>(); char temp = ' '; for(int i=0;i< str.length();i++) { temp = str.charAt(i); if (dic.containsKey(temp)) { dic.put(temp, 2); } else { dic.put(temp, 1); } } int time = 0; for(int i=0;i<str.length();i++){ temp = str.charAt(i); time = dic.get(temp); if(time ==1){ System.out.print(temp); return; } } System.out.print("no"); } public static void main(String[] args){ Solution35.findChar("abaccdef"); int[] tses ={1,2,3}; }}
阅读全文
0 0
- 剑指Offer --> Questions 35
- 【31-35】剑指offer
- 剑指Offer-35
- 剑指offer面试题35
- 剑指OFFER
- 剑指offer
- 剑指Offer
- 剑指offer
- 剑指Offer
- 剑指offer
- 剑指offer
- 剑指offer
- 剑指Offer
- 剑指offer
- 剑指offer
- 剑指Offer
- 剑指offer
- 剑指offer
- angular2结合angular-material2
- R语言绘制二元聚类图
- MT9V034摄像头采集
- 路由器的配置模式
- 【经典算法】Bellman-Ford最短路径算法
- 剑指Offer-35
- 安装my5.7
- 全局函数
- Ubuntu下 vi编辑方向键变成ABCD
- opencv+Qt5 知识点
- 感想
- 483. Smallest Good Base
- BZOJ 4518: [Sdoi2016]征途 斜率优化
- 速Geometric.Stackup.2.1.0.15228公差分析