One test case was not passed

hey @rachiitgupta, in insertionAtTail function, when head ==NULL, than your are creating node and making it head, after this you should return to calling function. Your function is checking other statements also.
Just place return after line no 34 and enclose them in braces of if.

Moreover, constraints of question are also very high, change datatype from int to long long.

Still does not work …

hey @rachiitgupta, just two mistakes in your code.

  1. in while loop of build function, you input 2 elements consecutively and then calling insertattail function.
  2. in while loop of kfromlast function, it should be fast!=NULL instead of fast->next!=NULL.

I have made changes to your code only, you can check them here https://ide.codingblocks.com/s/97791