Showing posts with label Leetcode 273: Integer to English words. Show all posts
Showing posts with label Leetcode 273: Integer to English words. Show all posts

Wednesday, July 18, 2018

Leetcode 273: Integer to English Words

July 18, 2018

Introduction


It is hard level algorithm. I had some discussion with a peer through mock interview more than three months ago. But I did not write code and did not submit anything through Leetcode online judge.

I know that it is important to write working code and pass online judge. And also I need to work hard to submit as many algorithms as  I can. The number cannot lie.

I have to submit code through Leetcode online judge, I like to demonstrate how hard I work on the practice. So I tried very hard to put together code today.

I like the effort I spent on the algorithm, although I still spent over 45 minutes to write code. I like to encourage myself to write more code in short future.

Every algorithm counts


It is best time for me to write a hard level algorithm when I have doubt for myself. I had good time to write code but there were so many mistakes in my code. I had to work on the bug fix depending on Leetcode online judge.

There are more than five places I stumbled this time since I had not written code a lot last few months.

Here is my C# code.

1. Line 19: Forty spell error: Fourty
2. Line 30, forgot to declare a variable called workingNumber,
3. Line 45, I did not reduce workingNumber to a smaller number first writing
4. Line 50, I tried to simplify the code, always a space is added
5. index out of range error, line 66, current is bigger than 1000 in my first running
6. current / 100 -> I wrote current % 100 at the first time, the bug was fixed
7. Line 77, biggerThan19 variable for the case is forgotten in my first writing


Life is so simple when I work hard to write code for a medium level algorithm. I just keep writing code and follow my coach's advice.

Time spent:

More than 30 minutes

My last practice is in the mock interview in March 2018. Here is the blog.

I just could not believe that I did not submit any code after March 2018 mock interview. It is important to get some training through Leetcode online judge.

Facts


As of July 18, 2018, solved 101/861, accepted submission: 759/511, Acceptance rate: 50.7% based on my Leetcode profile:
https://leetcode.com/jianminchen39/

Saturday, March 24, 2018

Being an interviewer: Leetcode 273: Integer to English words

March 24, 2018

Introduction


I have to say that I am a good JavaScript learner. I spent over 6 month full-time at work to learn JavaScript and then rewrote the JavaScript code for my current job back in 2015. One drill I like to do is to follow the peer when I interview on mock interview platform. On March 22, 2018, I had chance to watch how the peer worked on the algorithm using JavaScript.

It is also good learning experience of JavaScript by observing, and asking questions.

Code review


Here is JavaScript code to pass all kinds of test cases.

A few JavaScript features I like to look into:

Keywords:
Eval, const, $, ``,

I like to give the test case for the peer to work on,
let testNum = 1234567890



Friday, March 23, 2018

Leetcode 273: Integer to English Words

March 23, 2018

Introduction


I had a mock interview to work on the algorithm called Integer to English words. Since I had a mock interview on March 21, 2018, I visited my friend and did not have a 22 inches monitor to work on. It took me around 40 minutes to work on the algorithm.

It is challenging for me to read small font in the shared editor using my laptop monitor. I get used to read large font and can go over the code quickly using 22 inches monitor.

Being a good interviewer


I also like to advise my peer to learn to be a good interviewer. The interviewer should lead the interviewee to the optimal solution. I did tell the interviewer that I like to work on the solution based on the test case: 1, 234, 567, 890.

Here is my practice in mock interview.