For this Question: Given a linked list consisting of N nodes, your task is to check if the given list is palindrome or not.

A palindrome is a string/number that mirrors itself, for example, 21312 reverse is also 21312.User task:
Since this will be a functional problem, you don't have to take input. You just have to complete the functions <b>Ispalindrome()</b> that takes the head of the linked list as parameter.

Constraints:-
1<=N<=1000
1<=Node.data<=1000Return true if given list is palindrome else return false.Sample Input 1:-
5
1 2 3 2 1

Sample Output 1:-
Yes

Sample Input 2:-
3
1 2 2

Sample Output 2:-
No, I have written this Solution Code:   public static boolean IsPalindrome(Node head) 
  { 
  
        Node slow = head; 
        boolean ispalin = true; 
        Stack<Integer> stack = new Stack<Integer>(); 
  
        while (slow != null) { 
            stack.push(slow.val); 
            slow = slow.next; 
        } 
  
        while (head != null) { 
  
            int i = stack.pop(); 
            if (head.val == i) { 
                ispalin = true; 
            } 
            else { 
                ispalin = false; 
                break; 
            } 
            head = head.next; 
        } 
        return ispalin; 
    } , In this Programming Language: Java, Now tell me if this Code is compilable or not?