Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- static boolean isPalindrome(char[] c) {
- int l = 0, r = c.length - 1;
- while (l < r) {
- if (c[l] != c[r]) return false;
- l++;
- r--;
- }
- return true;
- }
- public static void main(String[] args) {
- char[] c = {'n', 'o', 'o', 'n'};
- System.out.print(isPalindrome(c));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment