# Run time error for one test case.

• Hi, I am having run time error, but I can't figure out what the problem is, because it runs fine on my local environment.

Submission Result: Runtime Error

Last executed input: {3,2,3,3,3,1,3,1,3,3,1,1,3,3,2,1,1,1,1,2,1,1,2,1,2,1,3,2,...........

``````public class Solution {
ListNode mid, temp;

//Find the middle node

//create two list, by breaking from the middle
temp = mid;
mid = mid.next;
temp.next = null;

//call mergeSort recursively
mid = sortList(mid);

//merge the two sorted list and return
}

ListNode currentNode1, currentNode2;

//check if there is 0 or 1 in the list

//start the pointer

//move till fast pointer reaches the end
while(currentNode2.next != null){

//move fast pointer by one
currentNode2 = currentNode2.next;

// check if end has reached or not
if(currentNode2.next == null)
return currentNode1;

//another move for fast pointer and a move for slow
currentNode2 = currentNode2.next;
currentNode1 = currentNode1.next;

}

//return the reference to the middle node
return currentNode1;

}

private ListNode mergeList(ListNode node1, ListNode node2){

ListNode result = null;

//check if first list is empty
if(node1 == null)
return node2;

//check if second list is empty
else if(node2 == null)
return node1;

//compare the two list and recursively call the method for merge
else if(node1.val <= node2.val){
result = node1;
result.next = mergeList(node1.next, node2);
}

else if(node1.val > node2.val){
result = node2;
result.next = mergeList(node1, node2.next);
}