- 博客(37)
- 收藏
- 关注
原创 Hadoop 常用命令
1、展示HDFS目录结构hadoop fs -ls [DIR][DIR] / 根目录/app app目录2、将HDFS中的文件拷贝到本地hadoop fs -get [REMOTE_DIR] [LOCAL_DIR][REMOTE_DIR] HDFS目录地址[LOCAL_DIR] 本地地址
2016-03-30 11:01:48
383
转载 C 语言 Signal 函数
C 语言 signal 函数,基本是根据系统中断,调用handler函数Example:#include #include #include #include void sighandler(int);int main(){ signal(SIGINT, sighandler); while(1) { printf("Going t
2015-12-21 16:11:24
649
转载 网络编程--IO模型示例(阻塞式IO)
IO模型在Richard Stevens的《UNIX网络编程,第一卷》(程序猿必备!)一书中有非常详尽的描述,以下简要介绍,并给出代码示例。另外比较好的总结性blog,推荐:使用异步 I/O 大大提高应用程序的性能IO - 同步,异步,阻塞,非阻塞 (亡羊补牢篇)常见网络IO模型:阻塞式IO、无阻塞式IO、IO复用、异步IO、信号驱动阻塞式IO:在一个进程发
2015-12-14 10:02:50
561
原创 Linux Shell 常用命令
1. 进程查询ps -ef | grep [感兴趣的进程]top2. 网络端口查询netstat -apn | grep [查询的端口]3. 查看文件/目录大小du -h [文件/目录]4. 拷贝文件/目录至当前使用机器scp [-r] [用户名]@[FROM地址IP]:[FRO文件/目录路径] [本地地址]lftp [用户名]@[FR
2015-10-15 18:38:01
638
原创 MySQL 常用命令
1. 数据库相关1.1 创建数据库create databse [数据库名];1.2 使用数据库use [数据库名]1.3 删除数据库drop database [数据库名]1.4 显示当前数据库show databases;1.5 登陆数据库mysql -u[用户名] -p[密码] -h[主机IP] -p[端口]2. 表相关2.1 显示数据
2015-10-15 18:30:24
345
原创 LeetCode #58 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined a
2015-10-08 17:48:34
323
原创 汉字数字转化为阿拉伯数字
#汉字数字转化为阿拉伯数字def hanTwoMoney(s): money = {u'一':1,u'二':2,u'三':3,u'四':4,u'五':5,u'六':6,u'七':7,u'八':8,u'九':9} if len(s) == 0: return None sum = 0 if len(s) >= 0: if money.has_key(s[len(s)-1]):
2015-09-08 19:52:39
896
原创 判断一个树是否为另一棵树的子树
class treeNode(object): def __init__(self, x): self.val = x self.left = None self.right = Nonedef loopTree(node): if node!= None: print node.val loopTree(node.left) loopTree(node.right
2015-09-07 22:22:50
674
转载 Binary Search 二分查找
def binarySearch(A,val): if A == None or len(A) == 0: return None l = 0 h = len(A) - 1 while l <= h: mid = l + (h-l) / 2 if A[mid] > val: h = mid - 1 elif A[mid] < val: l = mid +
2015-09-07 21:38:11
283
转载 5道经典的程序题 (5)
输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字。要求时间复杂度是O(n)。如果有多对数字的和等于输入的数字,输出任意一对即可。def sumVal(A,k): i = 0 j = len(A)-1 while i < j: if A[i] + A[j] > k: j-=1 elif A[i] + A[j] < k:
2015-09-04 21:34:07
459
转载 5道经典的程序题 (4)
求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。def nSum(n): if n == 0: return 0 return n + nSum(n-1)
2015-09-04 21:26:19
333
转载 5道经典的程序题 (3)
输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。句子中单词以空格符隔开。为简单起见,标点符号和普通字母一样处理。例如输入“I am a student.”,则输出“student. a am I”。def reverseSentense(S): i = 0 j = len(S) - 1 while i<j: temp = S[i] S[i
2015-09-04 18:06:02
383
转载 5道经典的程序题 (2)
输入n个整数,输出其中最小的k个。例如输入1,2,3,4,5,6,7和8这8个数字,则最小的4个数字为1,2,3和4。def minKValues(A,k): kValues = [] for i in range(0,k): kValues.append(A[i]) for i in range(k,len(A)): maxPos = 0
2015-09-04 13:44:36
352
转载 5道经典的程序题 (1)
题目1输入一个整形数组,数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)。例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5,和最大的子数组为3, 10, -4, 7, 2,因此输出为该子数组的和18。def maxSubArry(A): sumVal =
2015-09-03 22:15:17
439
转载 归并排序 MergeSort
def mergeSort(arry,left,right): if left < right: mid = (left + right) / 2 mergeSort(arry,left,mid) mergeSort(arry,mid+1,right) mergeArry(arry,left,right,mid) return arrydef mergeArry(arry
2015-08-16 11:14:23
305
转载 快速排序 QuickSort
def adjustArry(arry,left,right): i = left j = right x = arry[i] while i < j: while i= x: j-=1 if arry[j] < x: arry[i] = arry[j] i+=1 while i<j and arry[i] <= x: i+=1 if arry[
2015-08-11 17:02:31
298
原创 LeetCode #27 Remove Element
class Solution: # @param {integer[]} nums # @param {integer} val # @return {integer} def removeElement(self, nums, val): size = 0 for i in range(0,len(nums)):
2015-08-05 17:07:19
264
原创 LeetCode #26 Remove Duplicates from Sorted Array
class Solution: # @param {integer[]} nums # @return {integer} def removeDuplicates(self, nums): if len(nums) == 0: return 0 if len(nums) == 1: retur
2015-08-05 16:31:08
283
转载 LeetCode #22 Generate Parentheses
class Solution: # @param {integer} n # @return {string[]} def generateParenthesis(self, n): left = right = n s = '' sset = set() self.parentGen(s,left,righ
2015-08-05 12:01:29
292
原创 LeetCode #21 Merge Two Sorted Lists
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: # @param {ListNode} l1 # @param {ListNode
2015-08-04 21:37:18
271
原创 LeetCode #20 Valid Parentheses
class Solution: # @param {string} s # @return {boolean} def isValid(self, s): tack = [] for i in range(0,len(s)): if s[i] == '(' or s[i] == '{' or s[i] == '[' o
2015-07-24 08:37:15
317
原创 LeetCode #19 Remove Nth Node From End of List
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: # @param {ListNode} head # @param {intege
2015-07-23 11:57:42
260
转载 LeetCode #18 4Sum
class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer[][]} def fourSum(self, nums, target): valMap = {} ans = set() nums.sort()
2015-07-23 10:49:38
282
转载 LeetCode #17 Letter Combinations of a Phone Number
class Solution: # @param {string} digits # @return {string[]} def letterCombinations(self, digits): depth = 0 ans = [] path = "" self.comb(depth,ans,digits,
2015-07-21 11:25:43
366
原创 LeetCode #16 3Sum Closest
class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def threeSumClosest(self, nums, target): if len(nums) == 0: return None
2015-07-17 17:19:54
291
转载 【综述】(MIT博士)林达华老师-"概率模型与计算机视觉”
距上一次邀请中国科学院的樊彬老师为我们撰写图像特征描述符方面的综述(http://www.sigvc.org/bbs/thread-165-1-1.html)之后,这次我们荣幸地邀请到美国麻省理工学院(MIT)博士林达华老师为我们撰写“概率模型与计算机视觉”的最新综述。这次我们特别增设了一个问答环节,林老师针对论坛师生提出的许多问题(如概率图模型与目前很热的深度神经网络的联系和区别)一一做了详细解
2015-07-12 21:30:44
756
原创 LeetCode #15 3Sum
class Solution: # @param {integer[]} nums # @return {integer[][]} def threeSum(self, nums): if nums == None: return None if len(nums) == 0: return [
2015-07-12 15:44:12
280
原创 LeetCode #14 Longest Common Prefix
class Solution: # @param {string[]} strs # @return {string} def longestCommonPrefix(self, strs): if len(strs) == 0: return "" #find the longest substr
2015-07-12 10:40:16
308
原创 LeetCode #9 Palindrome Number
class Solution: # @param {integer} x # @return {boolean} def isPalindrome(self, x): if x < 0: return False y = 0 cX = x while x:
2015-07-12 10:02:45
311
原创 LeetCode #7 Reverse Integer
class Solution: # @param {integer} x # @return {integer} def reverse(self, x): isNegative = 1 y = 0.0 if x < 0: isNegative = -1 x = abs(x)
2015-07-11 19:00:47
471
原创 LeetCode#5 Longest Palindromic Substring
class Solution: # @param {string} s # @return {string} def longestPalindrome(self, s): lenS = len(s) maxLen = 0 maxStr = "" for i in range(0,lenS):
2015-07-11 18:17:50
465
转载 LeetCode#4 Median of Two Sorted Arrays (2)
def findKth(self,a,b,k,aStart,aEnd,bStart,bEnd): aLen = aEnd - aStart + 1 bLen = bEnd - bStart + 1 if aLen == 0: return b[bStart+k] if bLe
2015-07-09 12:23:29
400
原创 LeetCode#4 Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).class Solution: #
2015-07-04 07:21:25
383
原创 LeetCode #3 Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo
2015-07-03 13:43:14
316
原创 LeetCode #2 Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2015-07-03 07:51:55
391
原创 LeetCode #1 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe
2015-07-03 07:50:18
422
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人