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. Y...
分类:
编程语言 时间:
2014-11-24 10:10:53
阅读次数:
155
Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a...
分类:
其他好文 时间:
2014-11-21 20:12:47
阅读次数:
175
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((...
分类:
其他好文 时间:
2014-11-21 06:58:22
阅读次数:
262
众人皆知的是有两种:ipairs和pairs,这两种相信大家也是很了解了,其中ipairs是从头(idx=1)开始往后遍历,遇到nil即退出循环;而pairs则是顺序不定的遍历,只要里面有值都可以遍历的到。
那假如我需要顺序遍历而且即使中间有nil也能完整遍历到最后呢?
接下来就说这个:通过maxSize = table.maxn(t)获取到table最后一...
分类:
其他好文 时间:
2014-11-19 18:43:37
阅读次数:
236
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-11-19 15:41:29
阅读次数:
165
一、 JSON
(JavaScript Object Notation)一种简单的数据格式,比xml更轻巧。
Json建构于两种结构:
1、“名称/值”对的集合(A
collection of name/value pairs)。不同的语言中,它被理解为对象(object),纪录(record),结构(struct),字典(dictionary),哈希表(hash ta...
分类:
移动开发 时间:
2014-11-19 12:42:23
阅读次数:
266
Updating a DictionaryIn this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, and values are non-negative in...
分类:
其他好文 时间:
2014-11-19 07:04:07
阅读次数:
223
要使用httpd模块,需要在脚本开头添加: require "httpd" httpd.pairs(apr_table) 用以遍历apr_tablefor key, value in httpd.pairs(t) do body end 例: 1 require "httpd" 2 loca...
分类:
Web程序 时间:
2014-11-18 00:20:57
阅读次数:
195
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"思路分析:...
分类:
其他好文 时间:
2014-11-16 10:44:42
阅读次数:
164
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()...
分类:
其他好文 时间:
2014-11-13 16:36:06
阅读次数:
171