自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 [leetcode] 71.Simplify Path

题目: Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c” click to show corner cases.Corner Cases: Did you consider

2015-05-20 09:19:24 327

原创 [leetcode] 70.Climbing Stairs

题目: You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 题意: 你可以往上爬一个楼梯或者两格楼梯,到达顶端一共有n

2015-05-19 22:22:34 301

原创 [leetcode] 69.Sqrt(x)

题目: mplement int sqrt(int x).Compute and return the square root of x. 题意: 实现一个求平方的函数,参数是一个整数,返回的也是一个整数。 思路: 这道题很明显的使用二分查找。需要考虑特殊情况,比如说x是最大的整数之类的。 代码参见以下:class Solution {public: int mySqrt(in

2015-05-19 22:15:44 288

原创 [leetcode] 68.Text Justification

题目: Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that i

2015-05-12 13:18:09 344

原创 [leetcode] 67.Add Binary

题目: Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”. 题意: 给两个二进制数组的字符串,返回两者的和。 思路: 跟66题有些类似,也需要保存进位,需要考虑最高一位的进位情况。以上。代码如下:class Solut

2015-05-12 09:41:13 371

原创 [leetcode] 66.Plus One

题目: Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list. 题意: 将一个非负的整数按位放在一个数组里

2015-05-12 09:02:39 275

原创 [leetcode] 64.Minimum Path Sum

题目: 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

2015-05-11 23:42:36 322

原创 [leetcode] 63.Unique Paths II

题目: Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.F

2015-05-11 23:24:10 284

原创 [leetcode] 62.Unique Paths

题目: A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2015-05-10 16:06:04 329

原创 [leetcode] 60.Permutation Sequence

题目: 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 following sequence (ie, for n = 3):“123” “132” “213” “231”

2015-05-09 22:36:59 347

原创 [leetcode] 57.Insert Interval

题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Examp

2015-05-09 18:12:41 375

原创 [leetcode] 56.Merge Intervals

题目: Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. 题意: 给一些区间,合并所有的有重合的区间。比如上面的例子,区间[1,3]与区间[2,6]有重合,那么

2015-05-09 16:48:55 269

原创 [leetcode] 54.Spiral Matrix

题目: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Y

2015-05-09 14:07:40 338

原创 [leetcode] 53.Maximum Subarray

题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] ha

2015-05-09 10:17:52 323

原创 [leetcode] 52.N-Queens II

题目:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions. 题意:这道题与第51道题的不同是,这道题只需要返回一共有多少种可能,依旧采用回溯的方法来完成,只需要稍微改写第52道题的代码即可。 以上。

2015-05-09 09:30:24 367

原创 [leetcode] 51.N-Queens

题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle.E

2015-05-08 23:06:30 280

原创 [leetcode] 50.Pow(x, n)

题目:Implement pow(x, n). 题意:实现pow函数。 思路:这题需要做的是思考全面。在n=0时,直接返回1.在n>0时,直接让n个x相乘,当然n个x相乘的不需要o(n)的复杂度,只需要o(lgn)的复杂度,比如求100个2相乘,那么我们只要求得50个2相乘的结果,二分法只要o(lgn)复杂度。如果超过double的精度需要返回标记异常,比如面试官会让用一个全局变量记住。在

2015-05-08 10:31:39 374

原创 [leetcode] 49.Anagrams

题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case. 题意:给一个字符串数组,找出其中的所有的anagram组。anagram的意思是不同的单词但是含有相同的字符,这样的单词就称作anagram,比如veil,live,

2015-05-08 10:09:34 554

原创 [leetcode] 47.Permutations II

题目: For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. 题意:这道题相对于第46道题的变化是数组里面会有重复出现的元素,所以结题思路需要稍微变化。 思路:比如[-1,2,0,-1,1,0,1]这样数组,我们考虑第一位上可以放的数据一共有-1,0,1,2这四

2015-05-07 22:22:33 357

原创 [leetcode] 46.Permutations

题目:Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 题意是:给一个数字的集合,让你找出所有

2015-05-07 20:45:43 372

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除