S&P Global interview question

invert the linked list