LeetCode
文章平均质量分 60
lydxql
这个作者很懒,什么都没留下…
展开
-
LeetCode:Longest Common Prefix
class Solution: # @return a string def longestCommonPrefix(self, strs): if strs==[]: return '' else: l=len(strs[0]) base=strs[0]原创 2014-10-21 18:57:48 · 331 阅读 · 0 评论 -
LeetCode:Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.二分查找方法,原创 2014-10-15 15:58:50 · 275 阅读 · 0 评论 -
LeetCode:Maximum Depth of Binary Tree
# Definition for a binary tree node# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: # @param root, a原创 2014-10-15 16:06:14 · 305 阅读 · 0 评论 -
LeetCode:Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2014-10-15 16:10:48 · 281 阅读 · 0 评论 -
LeetCode:Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.原创 2014-10-15 23:46:44 · 292 阅读 · 0 评论 -
LeetCode:Reverse Words in a String
class Solution: # @param s, a string # @return a string def reverseWords(self, s): s=s.split() s.reverse() s=' '.join(s) return s原创 2014-10-15 23:47:59 · 575 阅读 · 0 评论 -
LeetCode:Single Number II
class Solution: # @param A, a list of integer # @return an integer def singleNumber(self, A): l=[] x=0 minus=0 for i in range(32): l.append(0)原创 2014-10-16 17:28:33 · 294 阅读 · 0 评论 -
LeetCode:Pow(x, n)
Implement pow(x, n).计算x的n次方。计算很容易,但是为了加快时间原创 2014-10-21 15:18:27 · 349 阅读 · 0 评论 -
LeetCode:Divide Two Integers
Divide two integers without using multiplication, division and mod operator.原创 2014-10-18 01:09:42 · 441 阅读 · 0 评论 -
LeetCode:Merge Sorted Array
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m andn respectively.原创 2014-10-20 19:10:01 · 353 阅读 · 0 评论 -
LeetCode:Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e原创 2014-10-15 15:57:59 · 276 阅读 · 0 评论 -
LeetCode:Same Tree
# Definition for a binary tree node# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: # @param p, a tre原创 2014-10-15 16:08:34 · 284 阅读 · 0 评论 -
LeetCode:Reverse Integer
从同事那里知道了这个东西,原创 2014-10-15 15:51:09 · 276 阅读 · 0 评论