题目
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 original relative order of the node...
分类:
其他好文 时间:
2014-06-11 06:28:41
阅读次数:
364
题目
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n =
4,
return 1->4->3->2->5->NULL.
Note:
Given m,...
分类:
其他好文 时间:
2014-06-11 06:07:11
阅读次数:
392
题目
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
方法
遍...
分类:
其他好文 时间:
2014-06-11 00:41:44
阅读次数:
207
ArrayList继承了List,
ArrayList没有继承List
List等价于List...
分类:
编程语言 时间:
2014-06-10 14:20:51
阅读次数:
262
分析:
问题是将给定的二叉树变换成令一种形式,这种类型的问题,其模式是,将左子树变换成某种形式,右子树也变换成这种形式,然后再与根结点按规定的方式连接起来,那么整体就变换完成了。这个题我们就可以采用这种形式,麻烦的地方就是在进行连接的时候,我们假设根为root,左子树变换后的根为root_left,右子树变换后的根为 root_right,那么连接的时候应该是root->right = root...
分类:
其他好文 时间:
2014-06-10 07:27:10
阅读次数:
201
问题:
给定一个有序链表,生成对应的平衡二叉搜索树。
分析
见Convert
Sorted Array to Binary Search Tree
实现:
TreeNode *buildTree(ListNode* head, ListNode *end){
if(head == NULL || head == end)
return NULL;
...
分类:
其他好文 时间:
2014-06-10 07:17:29
阅读次数:
264
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 创建日期:2014年6月9日 17:23:29
...
分类:
其他好文 时间:
2014-06-10 07:14:48
阅读次数:
164
Json编码,在python里就是一句话:
json.dumps(user_data)
但是Erlang没有自带的Json模块,只能自己造轮子:
先下载mochijson2:
https://github.com/mochi/mochiweb/blob/master/src/mochijson2.erl
用erlc编译
然后,上代码:
get_json_data() ->
...
分类:
Web程序 时间:
2014-06-10 06:46:21
阅读次数:
309
题目
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
方法
...
分类:
其他好文 时间:
2014-06-10 06:12:06
阅读次数:
285
很久没有写日志了,最近由于项目紧张在研究一些Java的反射机制,想利用该机制更好的完善和封装项目还有代码,今天在研究反射时,沈阳斌子遇到一个问题就是封装一个方法时有可变参数的问题,经上网查找找到如下方式和技巧。
编写Java程序时,经常会遇到一个方法需要多个参数的情况。例如一个求和方法:
public int add(int[] list){
int sum = 0;
for ...
分类:
编程语言 时间:
2014-06-10 06:08:52
阅读次数:
408