-
【leetcode】42-best-time-to-buy-and-sell-stock-iii 力扣 123. 买卖股票的最佳时机 III
买卖股票系列
【leetcode】40-best-time-to-buy-and-sell-stock 力扣 121. 买卖股票的最佳时机
【leetcode】41-best-time-to-buy-and-sell-stock-ii 力扣 122. 买卖股票的最佳时机 II
【leetcode】42-best-time-to-buy-and-sell-stock-iii 力扣 123...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】41-best-time-to-buy-and-sell-stock-ii 力扣 122. 买卖股票的最佳时机 II
买卖股票系列
【leetcode】40-best-time-to-buy-and-sell-stock 力扣 121. 买卖股票的最佳时机
【leetcode】41-best-time-to-buy-and-sell-stock-ii 力扣 122. 买卖股票的最佳时机 II
【leetcode】42-best-time-to-buy-and-sell-stock-iii 力扣 123...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】40-best-time-to-buy-and-sell-stock 力扣 121. 买卖股票的最佳时机
买卖股票系列
【leetcode】40-best-time-to-buy-and-sell-stock 力扣 121. 买卖股票的最佳时机
【leetcode】41-best-time-to-buy-and-sell-stock-ii 力扣 122. 买卖股票的最佳时机 II
【leetcode】42-best-time-to-buy-and-sell-stock-iii 力扣 123...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】020-39. 组合总和 Combination Sum + 40. 组合总和 II Combination Sum II + 77. 组合 combinations + 216. Combination Sum III + 377. 组合总和 Ⅳ
77. 组合
题目
给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。
你可以按 任何顺序 返回答案。
示例
示例 1:
输入:n = 4, k = 2
输出:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]
示例 2:
输入:n = 1, k = 1
输出:[[1]]
```...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】1882-1182. 与目标颜色间的最短距离
题目
题目描述
给你一个数组 colors,里面有 1、2、 3 三种颜色。
我们需要在 colors 上进行一些查询操作 queries,其中每个待查项都由两个整数 i 和 c 组成。
现在请你帮忙设计一个算法,查找从索引 i 到具有目标颜色 c 的元素之间的最短距离。
如果不存在解决方案,请返回 -1。
示例 1:
输入:colors = [1,1,2,1,3,2,2,3...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】019-36. 有效的数独 Valid Sudoku + 37. 解数独 sudoku solver
36. 有效的数独 Valid Sudoku
题目
请你判断一个 9 x 9 的数独是否有效。
只需要 根据以下规则 ,验证已经填入的数字是否有效即可。
数字 1-9 在每一行只能出现一次。
数字 1-9 在每一列只能出现一次。
数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。(请参考示例图)
注意:...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】018-34. 在排序数组中查找元素的第一个和最后一个位置 Find First and Last Position of Element in Sorted Array
写在前面
有些题目看起来很简单,深挖下去往往有很多值得深思的东西。
本文就来讨论一下二分查找法的问题,以及这道题背后真正想考察的东西。
34. 在排序数组中查找元素的第一个和最后一个位置
给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。
如果数组中不存在目标值 target,返回 [-1, -1]。
进阶:
你可...
2020-06-08 07:13:08 |
Algorithm
-
【leetcode】017-33. 搜索旋转排序数组 Search in Rotated Sorted Array + 81. Search in Rotated Sorted Array II + 153. Find Minimum in Rotated Sorted Array 寻找旋转排序数组中的最小值 + 154.Find Minimum in Rotated Sorted Array II
33. 搜索旋转排序数组 Search in Rotated Sorted Array
题目
整数数组 nums 按升序排列,数组中的值 互不相同 。
在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k+1], …, nums[n-1], nums[0], nums[1...
2020-06-08 07:13:08 |
Algorithm