Tuesday, May 15, 2018

Swap kth node with kth to last node in singly linked list (recursive solution)

May 15, 2018


Introduction


I had a mock interview this morning. I learned such important lesson in mock interview. Actually I tried to reconstruct a linked list involving four nodes in the linked list. Actually I can just swap values in those two nodes instead.

After the mock interview I also learned the lesson to write a recursive solution. Since I can write the algorithm in less than 10 minutes.

Mock interview


Here is the transcript at 8:00 AM mock interview.

Recursive solution


Here is my C# practice after the mock interview.

No comments:

Post a Comment