标签:字符串
public static Character FindFirstKChar(String str,int k){ String s = str.replaceAll(" ",""); Map<Character, Integer> charCountMap = new HashMap<Character, Integer>(); Character ch = null; for(int i = 0; i < s.length(); i++){ if(charCountMap.containsKey(s.charAt(i))){ charCountMap.put(s.charAt(i), charCountMap.get(s.charAt(i))+1); }else{ charCountMap.put(s.charAt(i), 1); } if(charCountMap.get(s.charAt(i))==k){ ch=s.charAt(i); break; } } return ch; }
本文出自 “递归的梦想偏执狂” 博客,请务必保留此出处http://rubinzhan.blog.51cto.com/11883911/1860188
标签:字符串
原文地址:http://rubinzhan.blog.51cto.com/11883911/1860188