May explain the mistake in my code


this is my code . i just try to use a simple approach . can you explain why it is not working .

First of all, since in your function you are calling other functions which throw exceptions, you need to add ‘throws Exception’ for your function as well. Further there are errors in the following lines:

Node back=this.getNodeAt(this.size);

forw=this.head.next;
back=this.getNodeAt(this.size-1-i);

Try to figure out the exact error (check indices you are accessing), doing a dry run with sample test cases will help. If you are still not able to find them, let me know.

yeah i got it … thanks

1 Like