BlooooooG


  • Home

  • Categories

  • Archives

  • Tags

  • Search

LeetCode Problem 45-Jump Game II

Posted on 2019-03-19 | In LeetCode | Visitors

跳跃游戏 II。给定一个非负整数数组,你最初位于数组的第一个位置。

数组中的每个元素代表你在该位置可以跳跃的最大长度。

你的目标是使用最少的跳跃次数到达数组的最后一个位置。

示例:

1
2
3
4
输入: [2,3,1,1,4]
输出: 2
解释: 跳到最后一个位置的最小跳跃数是 2。
     从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。

说明:

假设你总是可以到达数组的最后一个位置。

Read more »

LeetCode Problem 44-Wildcard Matching

Posted on 2019-03-19 | In LeetCode | Visitors

通配符匹配。给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。

1
2
'?' 可以匹配任何单个字符。
'*' 可以匹配任意字符串(包括空字符串)。

两个字符串完全匹配才算匹配成功。

说明:

  • s 可能为空,且只包含从 a-z 的小写字母。
  • p 可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。
Read more »

LeetCode Problem 49-Group Anagrams

Posted on 2019-03-18 | In LeetCode | Visitors

字母异位词分组。给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。

示例:

1
2
3
4
5
6
7
输入: ["eat", "tea", "tan", "ate", "nat", "bat"],
输出:
[
  ["ate","eat","tea"],
  ["nat","tan"],
  ["bat"]
]

说明:

  • 所有输入均为小写字母。
  • 不考虑答案输出的顺序。
Read more »

LeetCode Problem 48-Rotate Image

Posted on 2019-03-18 | In LeetCode | Visitors

旋转图像。给定一个 n × n 的二维矩阵表示一个图像,将图像顺时针旋转 90 度。

说明:

你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。

示例 1:

1
2
3
4
5
6
7
8
9
10
11
12
13
给定 matrix = 
[
  [1,2,3],
  [4,5,6],
  [7,8,9]
],

原地旋转输入矩阵,使其变为:
[
  [7,4,1],
  [8,5,2],
  [9,6,3]
]
Read more »

LeetCode Problem 47-Permutations II

Posted on 2019-03-18 | In LeetCode | Visitors

全排列 II。给定一个可包含重复数字的序列,返回所有不重复的全排列。

示例:

1
2
3
4
5
6
7
输入: [1,1,2]
输出:
[
  [1,1,2],
  [1,2,1],
  [2,1,1]
]
Read more »

LeetCode Problem 46-Permutations

Posted on 2019-03-18 | In LeetCode | Visitors

全排列。给定一个没有重复数字的序列,返回其所有可能的全排列。

示例:

1
2
3
4
5
6
7
8
9
10
输入: [1,2,3]
输出:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]
Read more »

LeetCode Problem 42-Trapping Rain Water

Posted on 2019-03-15 | In LeetCode | Visitors

接雨水。给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。

rainwatertrap

上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos贡献此图。

示例:

1
2
输入: [0,1,0,2,1,0,1,3,2,1,2,1]
输出: 6
Read more »

LeetCode Problem 43-Multiply Strings

Posted on 2019-03-14 | In LeetCode | Visitors

字符串相乘。给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。

示例 1:

1
2
输入: num1 = "2", num2 = "3"
输出: "6"

示例 2:

1
2
输入: num1 = "123", num2 = "456"
输出: "56088"
Read more »

LeetCode Problem 41-First Missing Positive

Posted on 2019-03-14 | In LeetCode | Visitors

缺失的第一个正数。给定一个未排序的整数数组,找出其中没有出现的最小的正整数。

示例 1:

1
2
输入: [1,2,0]
输出: 3

示例 2:

1
2
输入: [3,4,-1,1]
输出: 2
Read more »

LeetCode Problem 40-Combination Sum II

Posted on 2019-03-14 | In LeetCode | Visitors

组合总和 II。给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。

candidates 中的每个数字在每个组合中只能使用一次。

说明:

  • 所有数字(包括目标数)都是正整数。
  • 解集不能包含重复的组合。

示例 1:

1
2
3
4
5
6
7
8
输入: candidates = [10,1,2,7,6,1,5], target = 8,
所求解集为:
[
  [1, 7],
  [1, 2, 5],
  [2, 6],
  [1, 1, 6]
]
Read more »
1 … 7 8 9 … 14
Wendell Gu

Wendell Gu

138 posts
4 categories
68 tags
GitHub
© 2021 Wendell Gu
Powered by Jekyll
Theme - NexT.Mist
Storage Service - UPYUN