Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public class Solution{
  2.  
  3. //code I need Help with:
  4.  
  5. public static int palindromeCount(String s) {
  6. int count = 0;
  7. for (int i = 0; i < s.length(); i++) {
  8. for (int j = 0; j < s.length(); j++) {
  9. if (s.charAt(i) == s.charAt(j)) {
  10. }
  11. count++;
  12. }
  13. break;
  14. }
  15.  
  16. return count;
  17. }
  18.  
  19. //Given and can't change:
  20.  
  21. public static void main(String[] args) throws IOException {
  22. Scanner in = new Scanner(System.in);
  23. final String fileName = System.getenv("OUTPUT_PATH");
  24. BufferedWriter bw = null;
  25. if (fileName != null) {
  26. bw = new BufferedWriter(new FileWriter(fileName));
  27. } else {
  28. bw = new BufferedWriter(new OutputStreamWriter(System.out));
  29. }
  30.  
  31. int res;
  32. String s;
  33. try {
  34. s = in.nextLine();
  35. } catch (Exception e) {
  36. s = null;
  37. }
  38.  
  39. res = palindromeCount(s);
  40. bw.write(String.valueOf(res));
  41. bw.newLine();
  42.  
  43. bw.close();
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement