Introduction
Today I spent first 15 minutes to write code, and then I relied on my techniques using Terse, Express the intent, Do one thing (TED) principle, and then I made the change to look ahead to determine if it is ready to compare (line 33: readyToCompare), I passed all test cases in the 35th minute.
In summary, the algorithm I had to write is a linear scan algorithm, instead of looking ahead to determine if it is the last row in the current time stamp, first 25 minutes I worked on the idea to look backward to compare to previous time. Once I play with whiteboard testing, I figure out the solution 100% correctly.
Code review
C# code is here. Plan to highlight a few changes I made.
Line 29 - comment out line 29, the peer reminded me no need to use startNewTime, previousTimeStamp
Line 40 - max = sum; // the peer reminded me that sum is the new max value.
Actionable Item
Usually linear scan algorithm I should aim at 10 minutes to perform.
No comments:
Post a Comment