Thursday, September 6, 2018

Leetcode 400. Nth Digit - 6 failed submissions

Sept. 6, 2018

Introduction


It is the first easy level math algorithm I worked on. I chose Nth digit. I just could not believe that I came out the steps to work on, but my coding skills and also test skills did not catch up. I lost control of time and bugs were difficult to identify.

My practice with struggle 


Here is my first C# submission.

Failed test case:
input: 10
output: 0
expected: 1



Six failed submissions



It is such a battle against the following errors:

First submission, 27/70 test cases passed, failed test case:
input:10
output:0
Expected: 1

24/70 test cases passed, failed test case:
input: 11
output: 1
expected: 0

42/70 test cases passed, failed test case:
input: 100
output: 1
expected: 5

43/70 test cases passed, failed test case:
input: 1000
output: 4
expected: 3

Runtime Error
Unhandled Exception:
IndexoutofrangeException
getDigitInInteger

Wrong answer
43/70 test cases passed, failed test case:

Input: 1000
Output: 4
Expected: 3

Here is 6th failed submission - C# code. Here is the link I shared on discuss panel. 

I will write the working one based on the same idea. It is hard to write, I need to handle int out-of-range issue. It is best practice to learn how to handle integer out of range issue. 





No comments:

Post a Comment