Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-05-23 11:54:10
阅读次数:
317
题目:Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space ...
分类:
其他好文 时间:
2014-05-23 11:31:51
阅读次数:
299
【题目】
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
A sudoku puzzle...
...and its solution numbers marked in red.
...
分类:
其他好文 时间:
2014-05-20 17:07:34
阅读次数:
335
戳我去解题Given a linked list, remove thenthnode from
the end of list and return its head.For example, Given linked list:
1->2->3->4->5, and n = 2. Aft...
分类:
其他好文 时间:
2014-05-20 08:04:28
阅读次数:
291
【题目】
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will ...
分类:
其他好文 时间:
2014-05-18 18:48:03
阅读次数:
269
【题目】
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only n...
分类:
其他好文 时间:
2014-05-18 10:22:34
阅读次数:
367
Binary Tree Level Order Traversal
Total Accepted: 12441 Total
Submissions: 40879My Submissions
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left t...
分类:
其他好文 时间:
2014-05-18 10:11:13
阅读次数:
337
【题目】
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
【题意】
合并K个有序链表
【思路】
归并
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For ...
分类:
其他好文 时间:
2014-05-18 09:05:40
阅读次数:
255
【题目】
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. You may not modify the values in the list, only nodes it...
分类:
其他好文 时间:
2014-05-18 08:37:57
阅读次数:
370
Problem Description
For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 *
1. Now you are given two numbers A and...
分类:
其他好文 时间:
2014-05-18 06:35:50
阅读次数:
300