File tree 4 files changed +91
-4
lines changed
4 files changed +91
-4
lines changed Original file line number Diff line number Diff line change
1
+
2
+ ## 每日一题 - poker-reveal
3
+
4
+ ### 信息卡片
5
+
6
+ - 时间:2019-07-26
7
+ - 题目链接:无
8
+ - tag:` stack ` ` queue ` ` backtrack `
9
+
10
+ ### 题目描述
11
+
12
+ ```
13
+ 手中有 n 张牌
14
+ 第一张放桌上,第二张挪到手牌最下面,第三张放桌上,第四章挪到手牌最下面,
15
+ 循环直到所有牌都在桌上
16
+ 如果桌上牌的顺序是 1 - n
17
+ 原手牌顺序是什么?
18
+
19
+ i.e.
20
+ 如果有 5 张牌,桌上顺序是 1,2,3,4,5
21
+ 手中顺序是 1,5,2,4,3
22
+ 手中牌流程是:
23
+ 1 到桌上 5,2,4,3
24
+ 5 到牌尾 2,4,3,5,
25
+ 2 到桌上 4,3,5
26
+ 4 到牌尾 3,5,4
27
+ 3 到桌上 5,4
28
+ 5 到牌尾 4,5
29
+ 4 到桌上 5
30
+ 5 到牌尾 5
31
+ 5 到桌上
32
+
33
+ ```
34
+
35
+ ### 参考答案
36
+
37
+ 我们可以采取逆推理的方式来完成,假设我们现在桌上的扑克牌已经按照顺序排开了,
38
+ 我们让时间倒流,一步一步推倒出最初的时候手上的牌即可。
39
+ 这样的时间复杂度和空间复杂度都是O(n)
40
+
41
+ 大家可以对比看下leetcode 950号问题,这道题目是昨天题目的进阶版本(通用情况)。
42
+
43
+ 这里仅仅列举了950问题的参考代码: https://github.com/azl397985856/leetcode/blob/master/daily/answers/950.reveal-cards-in-increasing-order.js
44
+
45
+ ### 其他优秀解答
46
+
47
+ ```
48
+ 暂无
49
+ ```
Original file line number Diff line number Diff line change 1
- ## 每日一题 - mySqrt
1
+ ## 每日一题 - my-sqrt
2
2
3
3
### 信息卡片
4
4
5
5
- 时间:2019-06-21
6
- - 题目链接:- (但是 leetcode 上有一个相似的题目https://leetcode.com/problems/sqrtx/ )
6
+ - 题目链接:无
7
+ > leetcode 上有一个相似的[ 题目] ( https://leetcode.com/problems/sqrtx/ )
7
8
- tag:` binary search ` ` math `
8
9
9
10
### 题目描述
Original file line number Diff line number Diff line change
1
+ ## 每日一题 - deliver-medicine
2
+
3
+ ### 信息卡片
4
+
5
+ - 时间:2019-07-01
6
+ - 题目链接:无
7
+ - tag:` logic `
8
+
9
+ ### 题目描述
10
+
11
+ ```
12
+ A、B两人分别在两座岛上。B生病了,A有B所需要的药。C有一艘小船和一个可以上锁的箱子。C愿意在A和B之间运东西,但东西只能放在箱子里。只要箱子没被上锁,C都会偷走箱子里的东西,不管箱子里有什么。如果A和B各自有一把锁和只能开自己那把锁的钥匙,A应该如何把东西安全递交给B?
13
+
14
+ ```
15
+
16
+ ### 参考答案
17
+
18
+ 把药放在箱子,用自己的锁把箱子锁上。B拿到箱子后,再在箱子上加一把自己的锁。箱子运回A后,A取下自己的锁。箱子再运到B手中时,B取下自己的锁,获得药物。
19
+
20
+ ### 其他优秀解答
21
+
22
+ ```
23
+ 暂无
24
+ ```
Original file line number Diff line number Diff line change @@ -77,9 +77,22 @@ tag: `sql`
77
77
78
78
时间: 2019-06-21
79
79
80
- ### [ mySqrt] ( ./2019-06-27.md )
81
80
82
- tag: ` inary search ` ` math `
81
+ ### [ poker-reveal] ( ./2019-06-26.md )
82
+
83
+ tag: ` stack ` ` queue ` ` backtrack `
84
+
85
+ 时间: 2019-06-26
86
+
87
+ ### [ my-sqrt] ( ./2019-06-27.md )
88
+
89
+ tag: ` binary search ` ` math `
83
90
84
91
时间: 2019-06-27
85
92
93
+ ### [ deliver-medicine] ( ./2019-07-01.md )
94
+
95
+ tag: ` logic `
96
+
97
+ 时间: 2019-07-01
98
+
You can’t perform that action at this time.
0 commit comments