How do i optimise the code:https://ide.codingblocks.com/s/267965
Giving tle in all cases
hi @bhaskar0_0 since there can be multiple test cases, head1 and head2 need to be initialised with NULL for every test case. So just declare them inside the while loop, so they will get started with NULL each time.

Please mark your doubt as resolved in case of no further queries 