Introduction
It is a mistake when I write down the test case. I spent time to practice the algorithm called swap kth node with the kth from the end in a singly linked list. Here is C# code.
I made a mistake in my test case, line 37 and line 38 left hand variables are exactly the same, but I tried to find the bug in the algorithm. I spent over one hour and I could explain what kind of bug it was. The behavior was so strange, I used debugger but I could not explain.
My test case is a singly linked list fro 1->2->3->4->5->6, and I like to test the swap 2nd node with 2nd to last end one node. But I made a mistake in test function, the list is created only with 5 nodes, 1->2->3->4->5.
I felt frustrated, and almost exhausted. So I relaxed myself to review one of linked list practices. I came cross one of practice using recursive function. I decided to write a solution based on the recursive function. I found the mistake in test case setup in my code.
How to work with frustration?
I am so glad to experience the frustration again. I like to measure the level, what kind of actions I have, and later on I can come out good ideas to deal with those kind of mistake.
First let me measure the frustration level, give it rate 7 out of 10. I thought about doing really challenging practice on algorithm, but ended up working on trivial things.
I documented last time I came into tears after the mock interview. After I read the feedback from the interviewer. It is harsh and I Need to learn the lesson of learning harder.
Laundry list of excuses
I like to give possible reasons why I can not handle stress very well in my practice. I can think about several things, first not enough sleep; stress from principal applicant deadline, I need to fill the form for my nephew. And also I do not anticipate anything longer than one hour to write and debug.
In the morning mock interview, I did not simplify the task to swap two nodes's value but instead of working on node reconnects in the singly linked list. Through the mock interview, I learn that I may have done a lot of time at work, I should simplify the task first instead of messing with a complicated problem unnecessary.
I could not believe that I just did very good job for myself last week, and then next week I need to learn from the lesson again. Ask questions about the algorithm, dig deep. Define the requirement, seek the shortcut if there is one. solve the problem quickly first.
No comments:
Post a Comment