Saturday, October 13, 2018

Does my failure on Leetcode 150 easy level algorithms has a name?

Oct. 13, 2018

Introduction


It is time for me to spend 10 to 30 minutes to go over those failed submissions on 150 easy level algorithms. I like to identify what I should be careful, the growth pain of the algorithm and data structure problem solving. Like a baby growing up in the first year, there are numerous stages an infant can continuously develop. This is the first time I intensely work with the online judge, and work with those problem statements and problem setters, and also work with those hidden test cases which may never be released but may explode any time.

Common mistakes 


I make common mistakes very often. I just could not believe that I learn so much and so quickly through those easy level algorithms.

Sometimes the algorithms are labelled by the mistake as an easy level, but then I just fell in love with the algorithms and continue to learn from my experience. I choose the algorithm to be my mock interview algorithms more than five times.

Most surprisingly I learn a few solution with such elegant solution. I just could not believe that I need to refine my thinking process, and then rework the problem after my first submission by working independently.

I will list over 5 mistakes and lessons I learn in the following later.

687. Longest univalue path with design flaw, pass 43 out of 68 test cases
687. Longest univalue path copy the idea from most popular post
Array easy level algorithms (solved 44, shared 24)

867. Transpose matrix - pass 29/36 test cases
Math easy level algorithms (solved 27/ 32, shared 12)

415. Add Strings recursive version - memory limit exceeded
415. Add Strings Iterative solution - learn to use for loop creatively
String easy level algorithms (solved 32, shared 15) 
680. Valid Palindrome II 418/460 test cases passed Time limit exceeded
686. Repeated String Match memory limit exceeded for last test case
686. Repeated String Match memory limit exceeded for last test case
Hashtable easy level algorithm (solved 25, shared 21)

204. Count Primes verbose code
204. Count Primes elegant version

242. Valid Anagram One more mistake to remind me to work on easy level

500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf

645. Set Mismatch first submission - XOR
645. Set Mismatch elegant one using XOR two places
645. Set Mismatch use bit manipulation trick

720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function
Medium level (solved 53, shared 4)


915. Partition Array into Disjoint Intervals use three iterations
915. Partition Array into Disjoint Intervals one pass idea discuss
916. Word Subsets using counting sort
916. Word Subsets discuss
918. Maximum Sum Circular Subarray pass 98/108, in the contest
918. Maximum Sum Circular Subarray after the contest, working code
919. Complete Binary Tree Inserter O(1) insert
919. Complete Binary Tree Inserter Using Queue
919. Complete Binary Tree Inserter Using Queue
923. 3Sum With Multiplicity
923. 3Sum With Multiplicity dynamic programming solution 
Medium level tree algorithms (solved 14, total 39, shared 12)

102. Binary Tree Level Order Traversal submitted in 2015
102. Binary Tree Level Order Traversal submitted in 2018
Hard level (solved 33, shared 5)

37. Sudoku Solver
76. Minimum Window Substring One thing a time
85. Maximal Rectangle
239. Sliding Window Maximum optimal solution using LinkedList
239. Sliding Window Maximum All submissions, SortedSet, timeout

A name


I like to give those mistakes a name to encourage myself to work hard, work on more algorithm problem solving.

The name is called in Chinese, "这需要托大家的福,托大家的福就要吃百家饭、穿百家衣". The custom is to help raise a healthy child to eat and wear in so many families. The link is here.


No comments:

Post a Comment