- 博客(19)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode||67. Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".python自带的函数真简洁class Solution(object): def addBinary(self, a, b): """
2017-11-22 14:02:14 224
原创 LeetCode||66. Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digi
2017-11-22 11:37:06 211
原创 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
2017-11-22 10:46:14 221
原创 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
2017-11-21 14:28:46 248
原创 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
2017-11-21 13:51:52 219
原创 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
2017-11-20 14:06:42 222
原创 LeetCode||61. Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.Example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.先把链表连成环,再在特定的位置断开。注意k可能大于链表的长度。# De
2017-11-20 11:49:54 214
原创 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
2017-11-16 14:30:53 180
原创 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 ], [
2017-11-15 16:17:34 170
原创 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
2017-11-15 10:24:15 162
原创 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
2017-11-14 16:09:17 250
原创 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].先将区间按照每个start的值来排序,排好序以后判断一个区间的start值是否处在前一个区间中,如果在前
2017-11-14 15:59:03 182
原创 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
2017-11-10 11:37:36 177
原创 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 ]]
2017-11-09 14:08:46 199
原创 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
2017-11-08 15:24:50 176
原创 LeetCode||52. N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.这题比上一题简化一点,不用拍列出所有的情况,只要给个数字,思路还是回溯class Solution(object): de
2017-11-07 18:17:16 198
原创 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.
2017-11-06 17:11:09 221
原创 Leetcode||50. Pow(x, n)
Implement pow(x, n).实现幂的算法,需要考虑到正负数,我是用递归class Solution(object): def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ if n
2017-11-02 16:12:15 288
原创 Leetcode||49. Group Anagrams
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: Al
2017-11-02 15:58:52 204
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人