Wednesday, March 28, 2018

Work count practice

March 28, 2018

Introduction


It is very challenge algorithm to work on in 30 minutes. I have worked on the algorithm more than 6 times, but I never had chance to complete the code and pass all test cases in less than 30 minutes.

Today I also read the problem statement, I need to write code to keep the original order of words in the same bucket.

Code practice


Here is the C# code I wrote in 30 minutes in the mock interview. After the mock interview, I spent at least 30 minutes to complete the code and pass all test cases. Here is the C# code to pass all test cases.

Here are highlights of my work after mock interview:

1. line 18, Punctuation chars: "., !:;?", I missed :, ;, ?
2. line 22, Add function argument totalCount
3. line 22, function argument should be replaced, not orignal string document.
4. line 27 - line 41, I fail to call string.Replace to replace ' using empty char, so replaceChar function is written.
5. comment out line 16
6. Still confuse ToLower() function call, should string.ToLower() or document.ToLower()
Argument: string is class, not an interface, so ToLower is member function of string class, not interface member function.
7, line 57 and line 58, index variable should be used instead of using variable i defined on line 49.

No comments:

Post a Comment