For this Question: Given a linked list containing N nodes such that each nodes contains an additional random pointer, your task is to clone the given linked list into a new list and return the new head.<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>CloneList()</b> that takes the head of given list as parameter.

Constraints:
1 < = N < = 1000
1 < = Node.val < = 1000

<b> Custom Input:-</b>
First line of input should contains the number of Nodes N. Second line of input should contains N space separated integers depicting the data at each node. Last line of input should  N space separated integers contains the number of the node the random pointer is pointing to.

For eg:-
5
2 7 8 8 3 
1 2 2 3 2 You don't need to print anything you just need to return the head of the new list. You will get 1 if the cloning is done properly else you will get 0.Sample Input:-
4
1 2 3 4
1 4 1 1

Input Explanation:
1 - > 2 - > 3 - > 4
↓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;↓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;↓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;↓
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1

Sample Output:-
1, I have written this Solution Code: 
public static Node CloneList(Node head) {
	if (head == null)
		return null;
 
	Node p = head;
 
	// copy every node and insert to list
	while (p != null) {
		Node copy = new Node(p.val);
		copy.next = p.next;
		p.next = copy;
		p = copy.next;
	}
 
	// copy random pointer for each new node
	p = head;
	while (p != null) {
		if (p.random != null)
			p.next.random = p.random.next;
		p = p.next.next;
	}
 
	// break list to two
	p = head;
	Node newHead = head.next;
	while (p != null) {
		Node temp = p.next;
		p.next = temp.next;
		if (temp.next != null)
			temp.next = temp.next.next;
		p = p.next;
	}
 
	return newHead;
}

, In this Programming Language: Java, Now tell me if this Code is compilable or not?