Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
分类:
其他好文 时间:
2014-07-06 13:32:49
阅读次数:
204
#-*-coding:utf-8-*-#python:2.x__author__='Administrator'#functools:管理函数工具#作用:处理其他函数的函数#版本:2.5及之后#用于调整或者扩展函数和其他可回调对象,不用重写#修饰符:主要工具是partial在,用于包装,一个有默认参...
分类:
其他好文 时间:
2014-07-06 13:04:55
阅读次数:
206
可以练习下链表的逆置。
def PrintListReversingly(head):
if head == None:
return
if head:
PrintListReversingly(head.next)
print head.val
def reverse(head):
if head == None or head.next == None:
return...
分类:
其他好文 时间:
2014-07-06 09:29:57
阅读次数:
214
按他的方法排序,每次移动一个数到顶点,排成需要的序列。
Problem D: ShellSort
He made each turtle stand on another one's back
And he piled them all up in a nine-turtle stack.
And then Yertle climbed up. He sat down on the p...
分类:
其他好文 时间:
2014-07-06 09:15:42
阅读次数:
211
class BTNode:
def __init__(self, val):
self.left = None
self.right = None
self.val = val
'''
@ construct tree by inorder & preorder
'''
def constructByInPre(inorder, instart, inend, preorde...
分类:
其他好文 时间:
2014-07-06 00:34:00
阅读次数:
234
#-*-coding:utf-8-*-#python:2.x__author__='Administrator'#shutil#作用:高级文件操作#版本:1.4及以后#其他:包含了一些高级文件操作,如复制和设置限制importshutil,glob,os,StringIO,time#复制文件#cop...
分类:
其他好文 时间:
2014-07-05 22:35:39
阅读次数:
307
Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题目的意思是将相交得区间合并...
分类:
其他好文 时间:
2014-07-05 22:24:49
阅读次数:
177
Given two integers n and k, return all possible combinations of k numbers out of 1 ...n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4...
分类:
其他好文 时间:
2014-07-05 22:10:53
阅读次数:
226
f = open("foo.txt") # 返回一个文件对象line = f.readline() # 调用文件的 readline()方法while line: print line, # 后面跟 ',' 将忽略...
分类:
编程语言 时间:
2014-07-05 21:24:54
阅读次数:
287
最近需要做点支持linux的跨平台gui,网上查到了wxPython及Boa,感觉不错,照着Boa文档做做练习。代码:App:#!/usr/bin/env python#Boa:App:BoaAppimport wximport Frame1modules ={'Dialog1': [0, '', ...
分类:
编程语言 时间:
2014-07-05 21:21:40
阅读次数:
371