Reverse k Linked list


how to declare k in the reverse function should we recreate list in main after taking input from user??

you have to take input form user and the pass it to function
this should be done before function call
int k ;
cin>>k;

Input Format

The first line contains 2 space separated integers N and K

The next line contains N space separated integral elements of the list.

output is not correct plz have a look

there is one mistake

after while loop k will change
so when you pass it to next recursive call then it is wrong
so before using k make a copy of k

Modified Code

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved :grinning: