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
tomazi's solution for 100: Most Used Character, written in Java
import java.util.*; public class MostUsedCharacter { public String mostUsed(String sentence) { String[] words=sentence.split(" +"); int[] cs=new int[26]; int[] temp=new int[26]; for(int i=0; i<words.length; i++) { Arrays.fill(temp, 0); for(int j=0; j<words[i].length(); j++) { temp[words[i].charAt(j)-'a']=1; } for(int k=0; k<26; k++) { cs[k]+=temp[k]; } } int max=-1,mc=0; for(int i=0; i<26; i++) { if(cs[i]>max) { mc=i; max=cs[i]; } } String res=String.valueOf((char)('a'+mc)); return res; } }