随笔分类 - leetCode
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".题目并不复杂,以下是我的程序,后面是别人的程序,瞬间low了好大一截!冗长!!!!!!!cla...
阅读全文
摘要:ln 是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同步的链接.当我们需要在不同的目录,用到相同的文件时,我们不需要在 每一个需要的目录下都放一个必须相同的文件,我们只要在某个固定的目录,放上该文件,然后在其它的目录下用ln命令链接(link)它就可以,不必重复 的占...
阅读全文
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
阅读全文
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].本题我采用的是最直...
阅读全文
摘要:Description:Count the number of prime numbers less than a non-negative number,n.判断一个数是否是质数主要有以下几种方法:1)直接用该数除于所有小于它的数(非0,1),如果均不能被它整除,则其是质数;2)除以小于它一半的数...
阅读全文
摘要:Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 ...
阅读全文
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
阅读全文
摘要:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
阅读全文
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes...
阅读全文
摘要:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()...
阅读全文
摘要:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solv...
阅读全文
摘要:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
阅读全文
leetCode(41):Convert Sorted Array to Binary Search Tree 分类: leetCode 2015-07-17 17:03 95人阅读 评论(0) 收藏
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.取中间的结点作为根结点即平衡二叉树/** * Definition for a binary tree n...
阅读全文
摘要: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.Fo...
阅读全文
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ...
阅读全文

浙公网安备 33010602011771号