摘要: 1 /** 2 * Definition for binary tree with next pointer. 3 * struct TreeLinkNode { 4 * int val; 5 * TreeLinkNode *left, *right, *next; 6 * Tre... 阅读全文
posted @ 2014-04-22 12:53 beehard 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list in O(nlogn) time using constant space complexity. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int... 阅读全文
posted @ 2014-04-22 07:12 beehard 阅读(155) 评论(0) 推荐(0) 编辑
摘要: There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re... 阅读全文
posted @ 2014-04-22 06:23 beehard 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look l... 阅读全文
posted @ 2014-04-22 05:50 beehard 阅读(131) 评论(0) 推荐(0) 编辑
摘要: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font ... 阅读全文
posted @ 2014-04-22 04:57 beehard 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->... 阅读全文
posted @ 2014-04-22 04:06 beehard 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Pa... 阅读全文
posted @ 2014-04-22 03:47 beehard 阅读(145) 评论(0) 推荐(0) 编辑