摘要: Sort a linked list using insertion sort. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *nex... 阅读全文
posted @ 2014-04-15 22:56 beehard 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". Solution: '1'-'0' = 1. 1 class Solution... 阅读全文
posted @ 2014-04-15 13:16 beehard 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the ... 阅读全文
posted @ 2014-04-15 11:41 beehard 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial, could you do it iteratively? Solution: 1. Iterative way (... 阅读全文
posted @ 2014-04-15 11:06 beehard 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and... 阅读全文
posted @ 2014-04-15 10:45 beehard 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree. For example: Given the below binary tree, 1 ... 阅读全文
posted @ 2014-04-15 08:37 beehard 阅读(126) 评论(0) 推荐(0) 编辑