fork download
  1. import java.util.*;
  2. class Ideone {
  3. public static void main (String[] args) {
  4. System.out.println(findZenithLetter("I can reach the apex, at the top of the world."));
  5. System.out.println(findZenithLetter("I am Sam."));
  6. System.out.println(findZenithLetter("I am ~30 years old"));
  7. System.out.println("'"+findZenithLetter("$&@")+"'");
  8. System.out.println("'"+findZenithLetter("")+"'");
  9. }
  10. public static String findZenithLetter(String str) {
  11. if (str.isEmpty()) {
  12. return "";
  13. }
  14. String next = str.substring(0, 1);
  15. String rest = findZenithLetter(str.substring(1));
  16. return Character.isLetter(next.charAt(0)) && next.compareToIgnoreCase(rest) > 0 ? next : rest;
  17. }
  18. }
Success #stdin #stdout 0.12s 54152KB
stdin
Standard input is empty
stdout
x
S
y
''
''