What is problem in my code some test case are pass and some fail

public void appendLastN(int k) throws Exception {
	 if(k>=this.size) return;
   int n=size-k;
   Node temp=this.head;
   for(int i=0;i<n-1;i++ ) {
	   temp=temp.next;
   }
   Node t=this.head;
   this.head=temp.next;
   temp.next=null;
   temp=this.head;
   while(temp.next!=null) {
	   temp=temp.next;
   }
   temp.next=t;

}

@sksumitkumardiwaker,

Before calling the appendLastN method in main add the following code:
k = k % n;
if (k != 0)
list.appendLastN(k);

In case k>n, we will do k=k%n, because if k is 10, n is 7 this is same as k=3 and n=7. Also, add the if block because only run the code if k is not zero.

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.