Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. final boolean[] smallest = new boolean[26];
  3. final boolean[] largest = new boolean[26];
  4.  
  5. Arrays.fill(smallest, Boolean.FALSE);
  6. Arrays.fill(largest, Boolean.FALSE);
  7.  
  8. for (final Character c : s.toCharArray()) {
  9. if (Character.isLowerCase(c)) {
  10. final int index = c - 'a';
  11. smallest[index] = true;
  12. }
  13. else {
  14. final int index = c - 'A';
  15. largest[index] = true;
  16. }
  17. }
  18.  
  19. for (int i = 25; i >= 0; i--) {
  20. if (smallest[i] == true && largest[i] == true) {
  21. final String res = "" + (char)(i + 65);
  22.  
  23. return res;
  24. }
  25. }
  26.  
  27. return "No";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement