码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
#Leet Code# Divide Two Integers
描述:不使用 * / % 完成除法操作。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
pywin32创建一个窗口
```pythonimport win32con,win32guiclass MyWindow(): def __init__(self): #注册一个窗口类 wc = win32gui.WNDCLASS() wc.lpszClassName = 'M...
分类:Windows程序   时间:2014-07-16 18:59:22    阅读次数:843
ruby 类方法、实例方法、类变量
#######################类变量######################class Cloud @@count=0 def initialize(user,password,ip) @user = user @password ...
分类:其他好文   时间:2014-07-16 18:20:42    阅读次数:234
ruby 访问权限
###################### 访问权限#####################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
选择排序、插入排序、冒泡排序python实现
选择排序的时间复杂度为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
json 转 hash(MultiJson)
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
批量去重URL地址并剔除打不开网址
#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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!