# Monthly Archives: October 2015

## [leetcode] Binary Tree Longest Consecutive Sequence

Binary Tree Longest Consecutive Sequence Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to […]

## [leetcode] Serialize and Deserialize Binary Tree

Serialize and Deserialize Binary Tree Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer […]

## Learning Note for Functional Programming

Coursera Note Sentence in red is my own perspective, inspired by the instructor. 1.1 Programming Paradigms Imperative Programs and Computers There is strong correspondence between Mutable variables ~ Memory cells Variable dereference ~ load instructions Variable assignments ~ store instructions Control structures ~ jumps Problem: how can we avoid conceptualizing […]

## [leetcode] Best Meeting Point

Best Meeting Point A group of people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x […]

## [leetcode] Find Median from Data Stream

Find Median from Data Stream Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. Examples: [2,3,4] , the median is 3 [2,3], the median is […]

## [leetcode] Count Complete Tree Nodes

Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It […]

## [leetcode] Flip Game I && II

Flip Game You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive”++” into “–“. The game ends when a person can no longer make a move and therefore […]

## [leetcode] Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to […]

## [leetcode] Count Univalue Subtrees

Count Univalue Subtrees Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. For example: Given binary tree, 5 / \ 1 5 / \ \ 5 5 5 return 4. /** * Definition for a binary […]