February 28, 2016
Problem statement
Problems solved in the progression of coding:
1. Runtime error - exceed time limit
naive solution - compare each substring if it contains 00 or 11
2. Console.ReadLine only reads up to 256 chars, the input is up to 100000 chars.
3. Recursive calls - stack overflow - string length is up to 100000
4. Using iterative solution to replace recursive solution
First, wrote a solution in 20 minutes, but Time exceeding limit - TLE error.
Solution 1: C# code
Solution 2: C# code
So, write second version using recursive to avoid redundant calculation: stack overflow problem
Solution 3: C# code
Then, wrote third version with iterative solution:
Solution 4: C# code
(HackerRank embedded C# executable - wrong answer, but Visual express is ok! Cannot figure out! )
Spent more than 4 hours on this easy question. Totally invest 3 hours nonstop on Sunday afternoon on this problem solving.
What we say to encourage this behavior - have guts to fail. This is just the practice.
March 7, 2017
Need to review last practice and find out a solution.
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
No comments:
Post a Comment