Leetcode
更仔
这个作者很懒,什么都没留下…
展开
-
Leetcode:2. Add Two Numbers
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 ], [ 7, 6, 5原创 2016-04-04 00:53:45 · 198 阅读 · 0 评论 -
Leetcode:335. Self Crossing
You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3] metres to the east and so on. I原创 2016-05-20 21:12:05 · 233 阅读 · 0 评论 -
Leetcode:97. Interleaving String
Total Accepted: 48816 Total Submissions: 217231 Difficulty: HardGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aa原创 2016-05-01 13:02:40 · 214 阅读 · 0 评论 -
Leetcode:96. Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ /原创 2016-05-01 12:54:23 · 184 阅读 · 0 评论 -
Leetcode:91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of w原创 2016-05-01 12:37:48 · 165 阅读 · 0 评论 -
Leetcode:85. Maximal Rectangle
Difficulty: Hard Ac 44msGiven a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.这道题一开始并没有什么好的思路,只能先截取每行为底,对每列求高,简化成一列数组球最大面积的问题,这样的复杂度大概是o(原创 2016-05-01 12:28:33 · 275 阅读 · 0 评论 -
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比原创 2016-05-01 12:05:22 · 275 阅读 · 0 评论 -
Leetcode:64. Minimum Path Sum
AC 10msGiven 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原创 2016-05-01 10:53:55 · 195 阅读 · 0 评论 -
Leetcode:63. Unique Paths II
Total Accepted: 65084 Total Submissions: 221586 Difficulty: Medium time o(n*m) space o(n*m) Ac 0msFollow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique原创 2016-05-01 10:44:12 · 212 阅读 · 0 评论 -
Leetcode:62. Unique Paths
Total Accepted: 86496 Total Submissions: 238592 Difficulty: Mediumtime O(n*m) space o(n*m) AC 0msA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The r原创 2016-05-01 10:38:09 · 173 阅读 · 0 评论 -
Leetcode:53. Maximum Subarray
AC 4ms 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]原创 2016-05-01 10:14:35 · 200 阅读 · 0 评论 -
Leetcode:44. Wildcard Matching
Implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).The matching should cover the e原创 2016-05-01 10:00:36 · 184 阅读 · 0 评论 -
Leetcode:3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “原创 2016-04-04 23:33:13 · 227 阅读 · 0 评论 -
Leetcode:1. Two Sum
温故而知新(再不总结就忘了)Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given nums原创 2016-04-04 00:15:03 · 229 阅读 · 0 评论