Why its coming tle

hello @ayushwahi3005

a) image

here use else only. (besause ur if case is hadling < case , so rest other case should be handled inside else)

b) ur linked list formation code is O(n^2) which is the reason of tle.
so improve it.
how? just keep track of tail of ur list, for insertion of new node , simply add it to the tail and update ur tail.