Introduction Motivation We all know that the best time to do your homework is right before its due. However, the behavior of wait until the right time to do your homework

# Month: November 2016

## [LeetCode] (366) Find Leaves of Binary Tree

Source Basic Idea: since we strip one layer of leaves at a time, the time when a middle node got stripped is based on the height of its taller children

## [LeetCode] (463) Island Perimeter

Basic Idea: for each cell, add the number of legal sides to the solution. class Solution(object): def islandPerimeter(self, grid): """ :type grid: List[List[int]] :rtype: int """ if not grid: return

## [LeetCode] (459) Repeated Substring Pattern

Basic Idea: try to obtain the original string using all possible repeated substring from the shortest to the longest. class Solution(object): def repeatedSubstringPattern(self, str): """ :type str: str :rtype: bool

## [LeetCode] (455) Assign Cookies

Basic idea: using a greedy algorithm, prioritize satisfying kids with lower greed and assign cookies this way as many as possible. Implementation Apple: class Solution(object): def findContentChildren(self, g, s): """