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
KrvaviZmaj's solution for 100: Most Used Character, written in Java
import java.util.StringTokenizer; public class MostUsedCharacter { public String mostUsed(String sentence) { StringTokenizer st = new StringTokenizer(sentence, " "); String word; int[] occ = new int[26]; int max, koj; while (st.hasMoreElements()) { word = st.nextToken(); for (int i=0; i<26; i++) { if (word.indexOf(i+'a') != -1) { occ[i]++; } } } max = occ[0]; koj = 0; for (int i=1; i<26; i++) { if (occ[i] > max) { max = occ[i]; koj = i; } } char[] rez = new char[1]; rez[0] =(char)(koj+'a'); return new String(rez); } }