1. runtime error in code

https://hack.codingblocks.com/contests/c/424/302
https://ide.codingblocks.com/s/66490

HI Gaurav, please take the input according to specified input format. You are taking N1 first and then building list 1 whereas you have to take N1 then N2 and the build the both lists.
Also a suggestion, in your print function you are changing your head node always by:

head = head->next ;

Although this is working fine because once you display the list the program ends but you should also realize that the head reference to head of list gets lost so you should first make a temporary pointer and then operate on it to print the list so that for future operations it dosen’t get lost.

Hope this helps :slight_smile:


this is question showing in my challenges panel…
I code according to this question format

And I have passed head not as reference to print function so original head will remain same

Hi Gaurav, pls upload a screenshot of the problem statement here.

Hi Gaurav, pls see that your code is failing for a testcase where size of 1 list is 0. i.e.:

// Input
1
0
3
2 4 6

// Expected Output
2 4 6

// Your Output
Runtime Error

Ok got it…thanks

Hey Nargis, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.