Register
|
Login
Home
News
Competitions
Practice
How to
Rankings
Calendar
Arena
CodeFu 2007
CodeFu'07 Highlights
Jazoon'07 Highlights
Schedule
Rules
Prizes
Results
Competitions
»
Main CodeFu Competitons
»
CodeFu 2007
»
Results
CodeFu 2007 Results
CodeFu Final Round Results
aleksovski's solution for 100: Most Used Character, written in Java
public class MostUsedCharacter { int [] buk= new int[100]; public String mostUsed(String sentence) { String [] zb = sentence.split(" "); for (int i=0; i<zb.length; i++) if (zb[i].length()>0) { count(zb[i]); } int max=-1; char maxb='A'; for (char ch='a'; ch<='z';ch++) if (buk[ch-'a']>max) { maxb=ch; max=buk[ch-'a']; } return (new Character(maxb)).toString(); } private void count(String w) { for (char ch='a'; ch<='z';ch++) if (w.indexOf(ch)>=0) buk[ch-'a']++; } }