Let the Balloon Rise. 最近开始刷hdoj,想通过写博客做做笔记,记录写过代码. Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest i…
<script type="text/javascript"> //查找字符串中出现最多的字符和出现的次数 var str = 'Thatwheneying its on security.'; function find(str) { var max = 0, c; while(str) { var char = str.charAt(0); var a = str.split(char); var count = str.length - (str = a.join(&…
如何快速查找一个字符串中出现最多的字符,并统计出现的次数? 可以使用hash数组,也就是关联数组实现快速查找功能. function seek(str) { var hash = []; var max=-1; var max_key=''; for(var i=0,l=str.length;i<l;i++){ var key=str[i]; if(!hash[key]){ hash[key]=1; }else{ hash[key]++; } } //console.dir(hash); //遍…