Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
分类:
其他好文 时间:
2014-06-19 11:23:05
阅读次数:
204
问题
查找某个值在list中的位置
解决思路
可以用折半查询的方法解决此问题。
解决(Python)
#! /usr/bin/env python
#coding:utf-8
#折半查找某个元素在list中的位置
def half_search(lst,value,left,right):
length = len(lst)
while left<ri...
分类:
其他好文 时间:
2014-06-19 11:09:48
阅读次数:
527
问题
删除一个字符串中连续超过一次的空格。
解决(Python)
#! /usr/bin/env python
#coding:utf-8
def del_space(string):
split_string = string.split(" ") #以空格为分割,生成list,list中如果含有空格,则该空格是连续空格中的后一个
string_list =...
分类:
其他好文 时间:
2014-06-16 11:21:52
阅读次数:
204
Eclipse运行时提示“Failed to load the JNI shared library /Java/jre6/bin/client/jvm.dll”的一个解决方案
出现这个问题的一个原因是eclipse需要的64位jdk,你的环境变量中配的是32位jdk
于是有人建议,重装个64位的jdk,把环境变量换成64位的jdk,但如果你的其它程序需要32位jdk的话,这肯定不是一个好办法...
分类:
编程语言 时间:
2014-06-15 20:07:52
阅读次数:
419
#backup.sh
#!/bin/sh
#
# 第一次执行它的时候它会检查是否有完全备份,否则先创建一个全库备份
# 当你再次运行它的时候,它会根据脚本中的设定来基于之前的全库备份进行增量备份
#ocpyang@126.com
INNOBACKUPEX_PATH=innobackupex #INNOBACKUPEX的命令
INNOBACKUPEXFULL=/usr/bin/$IN...
分类:
数据库 时间:
2014-06-15 17:03:17
阅读次数:
271
ledisdb现在已经支持replication机制,为ledisdb的高可用做出了保障。使用假设master的ip为10.20.187.100,端口6380,slave的ip为10.20.187.101,端口为6380.首先我们需要master打开binlog支持,在配置文件中指定:use_bin_log : true
在slave的机器上面我们可以通过配置文件指定slaveof开启replic...
分类:
数据库 时间:
2014-06-15 16:44:32
阅读次数:
266
#!/usr/bin/python
# -*- coding: utf-8 -*-
# 8–2. 循环. 编写一个程序, 让用户输入三个数字: (f)rom, (t)o, 和 (i)ncrement .
# 以 i为步长, 从 f 计数到 t , 包括 f 和 t . 例如, 如果输入的是 f == 2,
# t == 26, i == 4 , 程序将输出 2, 6, 10,...
分类:
编程语言 时间:
2014-06-15 16:35:25
阅读次数:
444
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that
adding up all the values along the path equals the given sum.
For example:
Given the below bin...
分类:
其他好文 时间:
2014-06-15 09:34:35
阅读次数:
226
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at...
分类:
其他好文 时间:
2014-06-13 20:36:56
阅读次数:
280
本文简单讲述如何利用python执行一些sql语句,例如执行mysqldump命令,进行数据库备份,备份成sql文件#!/usr/bin/python#导入os模块import
os#导入时间模块import time#导入sys模块import sys#追加mysql的bin目录到环境变量sys....
分类:
数据库 时间:
2014-06-13 16:37:49
阅读次数:
447