Kth element from the end linkedlist


It is giving wrong answer in all the testcases.


added comments
update in build list
and k append function

1 Like

Thank you very much.But I have a doubt that why was data entered two times in the build function?

not twice
dekho jo apne liya tha
while ( data != -1) {}
without even entering data
vo glt tha
without entering data
u were checking -1 against a garbage value so initally
data lia
user se
check kia -1 h
nhi h to while chala
list meh add hua
then firse input lia
then while ki condition check hui

1 Like

Thanks I realized it.Thankyou