描述:不使用 * / % 完成除法操作。O(n)复杂度会超时,需要O(lg(n))复杂度。代码: 1 class Solution: 2 # @return an integer 3 def dividePositive(self, dividend, divisor): 4 ...
分类:
其他好文 时间:
2014-07-16 19:18:00
阅读次数:
298
```pythonimport win32con,win32guiclass MyWindow(): def __init__(self): #注册一个窗口类 wc = win32gui.WNDCLASS() wc.lpszClassName = 'M...
#######################类变量######################class Cloud @@count=0 def initialize(user,password,ip) @user = user @password ...
分类:
其他好文 时间:
2014-07-16 18:20:42
阅读次数:
234
###################### 访问权限#####################class HeidSoft##默认方法 def method1 ##### endprotected def method2 ##### endpri...
分类:
其他好文 时间:
2014-07-16 18:16:51
阅读次数:
156
先写下这个问题的模式
def preorderTraversal(self, root):
if root == None: return []
re = []
insert root to stack s
while s not empty:
cur_root = top of stack s
s.pop()
how to handle cur_root
how to ...
分类:
其他好文 时间:
2014-07-15 10:17:43
阅读次数:
274
def Median(t): """中位数""" arr = sorted(t) idx = (len(arr) - 1) / 2 if type(idx) is int: return arr[idx] if type(idx) is float: ...
分类:
其他好文 时间:
2014-07-14 23:49:19
阅读次数:
334
def Var(t, mu=None): """方差""" if mu is None: mu = Mean(t) # compute the squared deviations and return their mean. dev2 = [(x - mu)*...
分类:
其他好文 时间:
2014-07-14 23:28:48
阅读次数:
265
选择排序的时间复杂度为O(n^2),是不稳定的排序冒泡排序的时间复杂度最好情况下为O(n),最坏情况下为O(n^2),平均情况下为O(n^2),是稳定的排序插入排序的时间复杂度最好情况下为O(n),最坏情况下为O(n^2),,平均情况下为O(n^2),是稳定的排序1.选择排序def selectio...
分类:
编程语言 时间:
2014-07-14 19:40:48
阅读次数:
235
require 'multi_json'MultiJson.load('{"abc":"def"}') #=> {"abc" => "def"}MultiJson.load('{"abc":"def"}', :symbolize_keys => true) #=> {:abc => "def"}Mu...
分类:
Web程序 时间:
2014-07-14 19:05:34
阅读次数:
246
#coding=utf-8import osimport httplibimport socketdictlist ={};def ReadHost(): hosts = []; obn = open('d:/sss.txt', 'rb'); for line in obn: ...
分类:
其他好文 时间:
2014-07-14 16:01:28
阅读次数:
212