08 2015 档案
摘要:def findRepeatedDnaSequences(s): dix={s[:10]: 1} for i, c in enumerate(s[10:], 10): sub=s[i-9: i+1] if sub in dix:...
阅读全文
摘要:# Definition for a binary tree node# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# sel...
阅读全文
摘要:def ftd(n, d): intPart=n/d remain=(n%d)*10 decPart=[ ] dix={ } i=0 while True: dec=remain/d ...
阅读全文
摘要:class Solution: # @param {integer} n # @return {integer} def numTrees(self, n): nums=[0]*(n+1) nums[0]=1 for i in range(1, n+1): for j in range(1, i+...
阅读全文
摘要:# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: # ...
阅读全文
摘要:Problem Difinition:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the arr...
阅读全文
摘要:Just...Implement pow(x, n).Solution:1)Naive solution:multiply x by itself for n-1 times. (Or simply reyurn 1 if n==0).This takes O(n) time. When n is ...
阅读全文
摘要:Problem Definition:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Solution:要求把所有存在an...
阅读全文
摘要:Problem Definition:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-pl...
阅读全文
摘要:Problem Definition:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the ...
阅读全文
摘要:Problem Definition:Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,...
阅读全文
摘要:Problem Definition:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily lar...
阅读全文
摘要:Problem Definition:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers ...
阅读全文
摘要:Problem Definition:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to...
阅读全文
摘要:Problem Definition:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it ...
阅读全文
摘要:Problem Definition:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity...
阅读全文
摘要:A multiplication algorithm is an algorithm (or method) to multiply two numbers. Depending on the size of the numbers, different algorithms are in use....
阅读全文
摘要:1)写代码写代码写代码...多写写写--->用码表达Idea的能力2)理解掌握算法的核心Idea
阅读全文
摘要:Problem Definition:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrange...
阅读全文
摘要:Problem Definition:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Solution:就是要用加减和位操作之类...
阅读全文
摘要:Problem Definition:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as...
阅读全文
摘要:Problem Definition:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a ...
阅读全文
摘要:Problem Definition:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplet...
阅读全文

浙公网安备 33010602011771号