原题地址:https://oj.leetcode.com/problems/reverse-linked-list-ii/题意:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Gi...
分类:
编程语言 时间:
2014-09-14 23:38:47
阅读次数:
239
用C或C++实现void reverse( char* str )函数,即反转一个null结尾的字符串。分析:先确定字符串的长度,然后从两端往中间遍历,同时交换两端的元素。 1 #include 2 #include 3 #include 4 5 using namespace std; 6...
分类:
其他好文 时间:
2014-09-14 20:31:47
阅读次数:
209
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-09-13 20:08:35
阅读次数:
179
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2014-09-13 20:07:55
阅读次数:
287
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2014-09-13 20:06:25
阅读次数:
173
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321Have you thought about this?Here are some good questions to ask...
分类:
其他好文 时间:
2014-09-13 20:05:05
阅读次数:
189
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 1 /** 2 ...
分类:
其他好文 时间:
2014-09-13 20:03:15
阅读次数:
228
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2014-09-13 20:01:35
阅读次数:
185
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 ...
分类:
其他好文 时间:
2014-09-13 20:00:35
阅读次数:
207
定义链表结构struct ListNode{ int val; ListNode *next; ListNode(int v) : val(v), next(NULL) {}};非递归反转单链表ListNode* reverse(ListNode *root){ if (ro...
分类:
其他好文 时间:
2014-09-12 23:21:44
阅读次数:
235