不定期更新leetcode解题java答案。 采用pick one的方式选择题目。 本题很简单,大致翻译过来的意思是将单链表相邻节点互换节点位置。额外的要求是使用O(1)空间,以及不修改节点值,仅对节点位置修改。意思就是防止使用互换节点值的方式,省去交换节点位置的操作,这种取巧的方法。 思路很简单, ...
分类:
其他好文 时间:
2016-06-04 23:34:15
阅读次数:
169
问题描述:给一序列,交换每相邻的两个元素,并返回头结点。例如:1-2-3-4 返回序列2-1-4-3 算法思路:除了第一组元素,其他每次交换一对儿元素,要改变四个指针。所以,定义四个指针。其中只有两个指针是不想关,其他依赖这两个指针。 ...
分类:
其他好文 时间:
2016-05-30 23:14:18
阅读次数:
137
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。JSON采用完全独立于语言的文本格式,这些特性使JSON成为理想的数据交换语言。易于人阅读和编写,同时也易于机器解析和生成。
基础结构
JSON建构于两种结构:
1. “名称/值”对的集合(A collection of name/value pairs)。不同的语言中,它被理解为对象(obje...
分类:
Web程序 时间:
2016-05-29 12:24:57
阅读次数:
263
Problem: https://leetcode.com/problems/generate-parentheses/ Given n pairs of parentheses, write a function to generate all combinations of well-forme ...
分类:
其他好文 时间:
2016-05-29 00:39:52
阅读次数:
109
Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum clique i ...
分类:
其他好文 时间:
2016-05-26 13:08:23
阅读次数:
191
题目链接:
https://leetcode.com/problems/reconstruct-itinerary/题目:
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order....
分类:
其他好文 时间:
2016-05-23 15:15:34
阅读次数:
124
https://leetcode.com/problems/palindrome-pairs/ Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the ...
分类:
其他好文 时间:
2016-05-13 14:12:43
阅读次数:
232
Time Limit: 2000MS Memory Limit: 10000KDescriptionWrite a program that takes as input a rooted tree and a list of pairs of vertices. For each pair (u,v) the program determines the closest common a...
分类:
其他好文 时间:
2016-05-13 01:29:02
阅读次数:
241
Q:什么是活动函数?
----------
A:程序中被调用但还未执行完成的函数。
```
function g()
--[[ 此时函数"g"被调用但还未执行完成,是活动函数。所以这里获取的是函数"g"的信息。
"debug.getinfo(2)"获取的才是函数"f"的信息。]]
local x = debug.getinfo(1, "n")
for k, v in pairs(x) d...
分类:
其他好文 时间:
2016-05-13 00:44:36
阅读次数:
170
Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly
x distinct squares in the table consis...
分类:
其他好文 时间:
2016-05-12 12:24:59
阅读次数:
204