- 博客(16)
- 收藏
- 关注
原创 (Java)LeetCode-65. Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo
2016-10-07 20:41:05 387
原创 (Java)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
2016-10-07 16:25:49 949
原创 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
2016-10-07 15:30:13 278
原创 (Java)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
2016-10-06 21:54:21 587
原创 (Java)LeetCode-61. Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.这道题也不是很难。循环右移一个链表。要注意的是循环的位数可能会
2016-10-06 17:52:28 879
原创 (Java)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""3
2016-10-05 23:52:58 870
原创 (Java)LeetCode-59. Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2016-10-05 22:21:08 256
原创 (Java)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
2016-10-05 20:56:26 252
原创 (Java)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.E
2016-10-05 15:49:00 373
原创 (Java)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].这道题是Hard难度,看上去确实比较麻烦。最后居然AC了比较开心,虽然只打败了30%
2016-10-04 22:27:08 395
原创 (Java)LeetCode-55. Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2016-10-04 14:03:21 252
原创 (Java)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 ]]
2016-10-03 17:53:49 274
原创 (Java)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
2016-10-03 16:52:38 280
原创 (Java)LeetCode-52. N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.这一题和上一题一样嘛。。代码几乎一模一样,就是返回原来的List的Size而已~代码如下:public cla
2016-10-02 13:24:46 268
原创 (Java)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.
2016-10-01 21:51:19 263
原创 (Java)LeetCode-50. Pow(x, n)
Implement pow(x, n).这道题最慢时间复杂度也是O(n),快一些的是O(logn),主要是将n考虑为二进制的形式,某一位是1的话,就乘上相应的次方数即可。代码如下:public class Solution { public double myPow(double x, int n) { if(
2016-10-01 17:44:19 573
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人