Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For e...
分类:
其他好文 时间:
2014-08-11 14:44:32
阅读次数:
186
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]...
分类:
其他好文 时间:
2014-08-11 11:53:42
阅读次数:
185
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1...
分类:
其他好文 时间:
2014-08-11 11:45:02
阅读次数:
251
其实crbegin就相当于cbegin+rbegin.
关于这两个函数可以看我的上两篇博文。
public member function
std::vector::crbegin
const_reverse_iterator crbegin() const noexcept;
Return const_reverse_iterator to ...
分类:
其他好文 时间:
2014-08-11 08:27:33
阅读次数:
262
//逆置单链表,原地操作,只需要遍历一遍
private?ListNode?reverse(ListNode?head)
{
????ListNode?pre?=?null;
????ListNode?cur?=?head;
????while(cur!=null)
????{
???????...
分类:
其他好文 时间:
2014-08-10 13:12:50
阅读次数:
284
题目:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Outpu...
分类:
其他好文 时间:
2014-08-10 13:08:30
阅读次数:
296
说明:使用一个数字栈即可。(也可用数组链表模拟栈)
分类:
其他好文 时间:
2014-08-10 01:41:49
阅读次数:
191
public member function
std::vector::rbegin
C++98
C++11
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
Return reverse iterator...
分类:
其他好文 时间:
2014-08-09 23:22:42
阅读次数:
684
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 alternate between).
zigzag层序遍历树
For example:
Given binary...
分类:
其他好文 时间:
2014-08-09 23:19:59
阅读次数:
363
题目
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
click to show spoilers.
Have you thought about this?
Here are some good questions to ask...
分类:
其他好文 时间:
2014-08-09 00:13:36
阅读次数:
309