Beat 100% in O(N) complexity and O(1) space complexity..
Intuitionbrute forceApproachskip even length palindrome as always divisble by 11;Complexity

Time complexity:
O(N)


Space complexity:
O(1)

Code
# Intuition
brute force

# Approach
skip even length palindrome as always divisble by 11;

# Complexity
- Time complexity:
O(N)

- Space complexity:
O(1)

# Code
```java []
class Solution {
    public int primePalindrome(int n) {
        if (n > 7 && n <= 11) return 11;
        while (true) {

            String s = String.valueOf(n);
            int length = s.length();
            if (length % 2 == 0) {
                n =  (int) Math.pow(10, length) + 1;
            }

            if (isPalindrome(n)) {
                if (isPrime(n)) {
                    return n;
                }
            }
            n++;
        }
    }
    public boolean isPalindrome(int n) {
        int original = n;
        int reverse = 0;
        while (n != 0) {
            reverse = reverse * 10 + (n % 10);
            n /= 10;
        }
        return reverse == original;
    }
    public boolean isPrime(int n) {
        if (n < 2)
            return false;
        if (n == 2)
            return true;
        if (n % 2 == 0)
            return false;

        for (int i = 3; i <= Math.sqrt(n); i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }
}
```
['Java']