PikachuBLOG


  • 首页

  • 分类

  • 归档

  • 标签

  • 搜索

63. Unique Paths II

发表于 2017-07-27 | 分类于 LeetCode | 阅读次数
字数统计 857 | 阅读时长 4

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.

For example,
There is one obstacle in the middle of a 3x3 grid as illustrated below.

1
2
3
4
5
[
[0,0,0],
[0,1,0],
[0,0,0]
]

The total number of unique paths is 2.

Note: m and n will be at most 100.

阅读全文 »

62. Unique Paths

发表于 2017-07-27 | 分类于 LeetCode | 阅读次数
字数统计 412 | 阅读时长 2

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 bottom-right corner of the grid (marked ‘Finish’ in the diagram below).
How many possible unique paths are there?
62-robot_maze
Above is a 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.

阅读全文 »

61. Rotate List

发表于 2017-07-26 | 分类于 LeetCode | 阅读次数
字数统计 405 | 阅读时长 2

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.

阅读全文 »

60. Permutation Sequence

发表于 2017-07-26 | 分类于 LeetCode | 阅读次数
字数统计 1,377 | 阅读时长 7

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”
  “312”
  “321”
Given n and k, return the kth permutation sequence.

Note: Given n will be between 1 and 9 inclusive.

阅读全文 »

59. Spiral Matrix II

发表于 2017-07-26 | 分类于 LeetCode | 阅读次数
字数统计 381 | 阅读时长 2

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 ],
 [ 7, 6, 5 ]
]

阅读全文 »

58. Length of Last Word

发表于 2017-07-26 | 分类于 LeetCode | 阅读次数
字数统计 302 | 阅读时长 2

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 defined as a character sequence consists of non-space characters only.

For example,
Given s = “Hello World”,
return 5.

阅读全文 »

57. Insert Interval

发表于 2017-07-25 | 分类于 LeetCode | 阅读次数
字数统计 454 | 阅读时长 2

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.

Example 1:
Given intervals[1, 3], [6, 9], insert and merge[2, 5] in as[1, 5], [6, 9].

Example 2 :
​ Given[1, 2], [3, 5], [6, 7], [8, 10], [12, 16], insert and merge[4, 9] in as[1, 2], [3, 10], [12, 16].
​ This is because the new interval[4, 9] overlaps with[3, 5], [6, 7], [8, 10].

阅读全文 »

56. Merge Intervals

发表于 2017-07-25 | 分类于 LeetCode | 阅读次数
字数统计 606 | 阅读时长 3

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].

阅读全文 »

55. Jump Game

发表于 2017-07-25 | 分类于 LeetCode | 阅读次数
字数统计 801 | 阅读时长 4

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 if you are able to reach the last index.

For example:
A = [2,3,1,1,4], return true.
A = [3,2,1,0,4], return false.

阅读全文 »

54. Spiral Matrix

发表于 2017-07-25 | 分类于 LeetCode | 阅读次数
字数统计 817 | 阅读时长 4

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 ]
]
You should return [1,2,3,6,9,8,7,4,5].

阅读全文 »
1…111213…17
CodePikachu

CodePikachu

技术随笔

168 日志
5 分类
7 标签
RSS
GitHub Twitter 微博 知乎
0%
© 2015 - 2020 CodePikachu
博客全站共123.3k字
本站访客数:
由 Hexo 强力驱动
主题 - NexT.Pisces