why i m getting 3 test cases wrong…i’ve tried all the possible things…please help…take a look on the code given…
K append Linked List problem
hey @nikhilmeena,it is mentioned in the problem that k can be greater than n so you have to consider that case you cant just return 0 when your k>n.
what you have to do is take k=k%n .
and print the same aray only when k=0(k==n gives k=0 by taking modulo).
In your code check line 66 if k >n then you might point your next to null variable.
Also try a simpler approach.
Since you have to move last k elements to the front just make the n-kth term as head and then point the next of current last element as the previous head.
And if k>n your answer won’t change.
Do check these cases and submit again.
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.
i m still getting two test cases wrong …i’ve done the case when k>n and append k%n elements…but still not geeting full score
Hi @nikhilmeena
Your code is showing wrong ans for test cases where k>n1. So for that what you need to do is that k=k%n1; after taking k as input from user. Also after this you need to change the if condition that is k==n1 to k==0 as when you take k%n1 then if k==n1 then after taking its modulo it becomes zero and then you need to print the linked list as it is.
Here is your corrected code :
If your doubt is clear then mark it as resolved.
@aman212yadav,why are you marking someone else doubt as resolved even when doubt is not get cleared by the student.
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.
- create a linked list
- enter a key who’s left you want to insert your element.
- I haven’t written code for display the list and creating a list you Canon Printer Repair can write it on your
