Showing posts with label code challenge. Show all posts
Showing posts with label code challenge. Show all posts

Saturday, July 15, 2017

Coding challenge

July 15, 2017

Introduction


It is very challenge task to compete in less than three hours contest. Specially hour rank on Hackerrank. Julia did a few of Leetcode weekly contests, one algorithm Leetcode 605: Can plant flower, one time she spent over 30 minutes on easy algorithm, but she learned to write a solution after the contest in less than 10 minutes.

How to prepare a coding assessment challenge? How to review Leetcode algorithms? How to warm up a few hours before taking the test?

Challenge 



July 20, 2017
It is important to work on a few algorithms, write some blogs, and document real learning experience. Julia enjoys the algorithm problem solving, she also noticed that she should take some time to review what she learned last 3 months.

Julia spent one week to prepare, she did study a few algorithms and enjoyed most of them. The best one is to work on the algorithm called maze. The idea is to work on simple things, implementation, time to complete the coding, comparison among various solutions, learn to write a quick and complete solution in less than 5 minutes.

She spent last 3 hours to print out all source code she worked on Leetcode last 3 months, almost 30 algorithm. She reviewed all of them one by one, spent a few minutes on each of them. She was so touched by her hard work, she did learn a few things through those practice.

So when she started to work on code challenge, she was very calm. She shifted her focus on things she could control. She felt that she was mature enough for another assessment, since she reviewed and also learned something new. She likes to check honestly if she can handle challenge, solve problems.

Sunday, February 28, 2016

code challenge: count of substring

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.