For this Question: Sara has 2*N chocolate boxes with uneven chocolates in them. She wants to distribute the boxes to N of her students. For each student, Sara will pick one box from the start and one box from the end. Since the chocolates are uneven Sara wants to know the maximum number of chocolates a student received.

The boxes are represented by a singly linked list in which each node represents the number of chocolates in the current box.<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>maxChocolates()</b> that takes the head node of the linked list as a parameter.

<b>Constraints:</b>
1 <=N <= 5000
1 <=node.data<= 10000Print the maximum number of chocolates a student received.Sample Input:-
5
1 2 3 4 5 3 2 1 4 5

Sample Output:-
8

Explanation:-
Given list:- 1- >2- >3- >4- >5- >3- >2- >1- >4- >5
Student 1 received:- 1 + 5 = 6
Student 2 received:- 2 + 4 = 6
Student 3 received:- 3 + 1 = 4
Student 4 received:- 4 + 2 = 6
Student 5 received:- 5 + 3 = 8

Sample Input:-
2
1 4 2 3

Sample Output:-
6, I have written this Solution Code: public static int maxChocolates(Node head) {

        Node temp = head;
        int n=0;
        while(temp!=null){
            temp=temp.next;
        
            n++;
        }
            int x = n/2;
           temp=head;
          while(x-->0){
            temp=temp.next;
        }
        Node p = temp.next;
        temp.next = null;
        Node h;
        while(p!=null){
            h=p.next;
            p.next=temp;
            temp=p;
            p=h;
        }
        x=n/2;
        int ans=0;
        while(x-->0){
            ans=Math.max(ans,head.val+temp.val);
            temp=temp.next;
            head=head.next;
        }
        return ans;
        }, In this Programming Language: Java, Now tell me if this Code is compilable or not?