Data structure stores a sequence of items in a list
|List | Java | Python | Go |
|:------------|:---------------------------------|:----------|:--------------------|
|type | List, Arraylist, LinkedList | list | List |
|package | im继续阅读 »
Question
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
Try to do this in one pass.
解说
这道题的意思是,如何反向删继续阅读 »
In recent years, non-relational data have attracted more and more attentions. Roughly speaking, all datasets that are hard to put into a rectangular table with rows and columns are non-relational datasets.继续阅读 »
rlist 0.3 is released! This package now provides a wide range of functions for dealing with list objects. It can be especially useful when they are used to store non-tabular data.继续阅读 »
1. 枚举 - enumerate 可以有参数哦
之前我们这样操作:
i = 0
for item in iterable:
print i, item
i += 1
现在我们这样操作:
for i, item in enumerate(iterable):
print i, item
enumerate函数还可以接收第二个参数。就像下面这样:
list(enumerate('abc'))
[(0, 'a'), (1, 'b'), (2, 'c')]
list(enumerate('abc', 1))
[(1, 'a'), (2, 'b'), (3, 'c'继续阅读 »