LL-k Reverse Why runtime error?

public void reverse(int k,int N)throws Exception
{
for(int i=0;i<N;i=i+k)
{
int l=i;
int h=k+i-1;
Node low=getNodeAt(i);;
Node high=getNodeAt(h);
while(l<h)
{
int temp=getAt(l);
low.data=high.data;
high.data=temp;
l++;
h–;
low=low.next;
high=getNodeAt(h-1);
}

	}

Also say is it the correct approach to slve this problem?

@Rahul-Kumar-2389849724440887,
https://ide.codingblocks.com/s/221925 here is the suggested approach.

  1. Reverse the first sub-list of size k.1.1 While reversing keep track of the next node and previous node.1.2 Let the pointer to the next node be next and pointer to the previous node be prev.
  2. head->next = reverse(next, k) - Recursively call for rest of the list and link the two sub-lists
  3. return prev - prev becomes the new head of the list (see the diagrams of iterative method of this post)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.