Advertisement
unknown_0711

Untitled

Nov 16th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main {
  6. public static void main(String[] args) throws java.lang.Exception {
  7. // youwhiler code here
  8. Scanner sc = new Scanner(System.in);
  9. String s = sc.nextLine();
  10. s = s.toLowerCase();
  11. int n = s.length();
  12. int count = 0;
  13. int i = 0;
  14. int j = n - 1;
  15. while (i < j) {
  16. // System.out.println(s.charAt(i) + " " + s.charAt(j));
  17. if ((s.charAt(i) >= 'a' && s.charAt(i) <= 'z') && (s.charAt(j) >= 'a' && s.charAt(j) <= 'z')) {
  18. if (s.charAt(i) != s.charAt(j)) {
  19. count++;
  20. break;
  21. }
  22. i++;
  23. j--;
  24. } else if (s.charAt(i) < 'a' || s.charAt(i) > 'z') {
  25. i++;
  26. } else if (s.charAt(j) < 'a' || s.charAt(j) > 'z') {
  27. j--;
  28. }
  29.  
  30. }
  31. if (count == 0)
  32. System.out.print(1);
  33. else
  34. System.out.print(0);
  35. }
  36. }
  37.  
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement