Sort a topologically sorted linked list with both positive and negative numbers
Anonymous
I first answered that remove negative nodes from list and keep attaching them to tail of new list, in the end join tail of negative node with head of of old list. Interviewer said it was too complicated Then I presented another solution , maintaining last negative node variable, and keep moving all negative elements to previous of last negative node. Interviewer said I was using too many variables Later interviewer himself answered that I just need to make any negative element new head. Which was also what I was doing except I was using new last_negative_node variable instead of just head
Check out your Company Bowl for anonymous work chats.