分类
Life

Life should be colorful.

Colorful Week Life should be as colorful as this calend […]

分类
C++ Develop 算法

Algorithm Problem: In-Place Merge Sort

The original merge sort version will take O(n) space, a […]

分类
C++ Develop 算法

LeetCode Problem: Populating Next Right Pointers in Each Node II

The code in the previous article LeetCode Problem: Popu […]

分类
C++ Develop 算法

LeetCode Problem: Populating Next Right Pointers in Each Node, Level traversal of binary tree

It’s easy to doing this by using a queue, doing a […]

分类
C++ Develop 算法

Algorithm Problem: Longest Non-Descending Sub Array or Logest Increasing Subarray, Dynamic programming

The ordinary dynamic programing gives our an algorithm […]

分类
C++ Develop 算法

Algoritm Problem: Add Two Unsigned Integers

To add two unsigned integers, A and B, we can exam a bi […]

分类
Develop iOS

How to Deploy iOS Applications into Any Device out of Apple Store

Pre-Conditions: You have an apple developer account. Th […]

分类
C++ Develop 算法

Algorithm Problems: Two Sum

Manage two pointer to the array, one from the front, mo […]

分类
C++ Develop 算法

Algorithm Problem:Swap the left and right sub-tree in a binary tree without recursion

Just swap the tree nodes’ left and right child, i […]

分类
Develop iOS

How to make a call using iOS SDK

It’s pretty simple, just one line of code: 用iOS S […]

分类
Develop iOS

iOS开发和服务器通讯遇到的编码问题

今天遇到一个bug,是服务器那边传过来的用UTF8编码之后的Json字符串,解UTF8之后,Json解析失败。 […]

分类
C++ Develop 算法

Algorithm Problem:Intersection of Sorted Array

Binary search every element of arr1 in arr0, if find, a […]

分类
C++ Develop 算法

LeetCode Problem:Flatten Binary Tree to Linked List

We can notice that in the flattened tree, each sub node […]

分类
C++ Develop 算法

Algorithm Sqrt for Double

The binary divide is straight forward solution, but som […]

分类
C++ Develop 算法

Algorithm Problem: Coins,Integer Bag Problem using Dynamic Programming

We can calculate the result by dynamic programming. Whe […]

分类
C++ Develop 算法

LeetCode Problem:Distinct Subsequences

(2013-1-5更新了动态规划版本,见下面) 这题有点复杂,一开始拿到都不知道怎么下手。 尝试的路径是: 1 […]

分类
C++ Develop 算法

题目:Max Ascending

问题比较简单,就是一个数组a[n] 求max(ai-aj), i<j. 从前往后扫描,记录下当前的最小值 […]

分类
C++ Develop 算法

LeetCode题目:Convert Sorted List to Binary Search Tree

问题比上一个难一点,如果是可以用O(n)空间的话,倒是可以开一个数组放上这n个数,然后按上一个问题的解法去做。 […]

分类
C++ Develop 算法

LeetCode题目:Convert Sorted Array to Binary Search Tree

对排序的数组进行二分查找样式的遍历就行了。 Convert Sorted Array to Binary Se […]

分类
C++ Develop 算法

LeetCode题目:Construct Binary Tree from Inorder and Postorder Traversal

这题和上一道题类似,也是首先在postorder中,最后那一个肯定是整棵树的根,然后在inorder中查找这个 […]

分类
C++ Develop 算法

LeetCode题目:Construct Binary Tree from Preorder and Inorder Traversal

这曾经是一道很难的题目,看来这一阵的锻炼确实是有效果的。 方法是,画一棵树出来,比如: 1 / \ 2 3 \ […]

分类
C++ Develop 算法

LeetCode题目:Binary Tree Zigzag Level Order Traversal

比较简单,广度优先变一下就可以了,用一个bool记录是从左到右还是从右到左,每一层结束就翻转一下。 Binar […]

分类
C++ Develop 算法

LeetCode题目:Binary Tree Maximum Path Sum

这道题好难,因为在一颗二叉树中有多种情况,这条最长的路径有可能是从某个中间节点直接到某个叶子节点的,也有可能是 […]

分类
C++ Develop 算法

LeetCode题目:Binary Tree Level Order Traversal II

和上一题差不多,只不过最后输出的时候颠倒一下,另外:std::list才有push_front(),而std: […]

分类
C++ Develop 算法

LeetCode题目:Binary Tree Level Order Traversal

题目简单,经典方法。只不过这题需要每一个level单独作为一个vector输出,因此在每一个level结束的时 […]

分类
C++ Develop 算法

LeetCode题目:Best Time to Buy and Sell Stock III,一维动态规划

和前两道题比起来的话,这道题最难了,因为限制了交易次数。 解决问题的途径我想出来的是:既然最多只能完成两笔交易 […]

分类
C++ Develop 算法

LeetCode题目:Best Time to Buy and Sell Stock II

这个更简单了,题目要求可以多次买卖,但是同一时间只能有一股在手里。 这样就可以在每次上升子序列之前买入,在上升 […]

分类
C++ Develop 算法

LeetCode题目:Best Time to Buy and Sell Stock

这个很简单,一次扫描完成。只需要找到最大增长即可。 从前往后,用当前价格减去此前最低价格,就是在当前点卖出股票 […]