Skip to content

Commit 23f9873

Browse files
author
arbent
committed
2018/9/15
1 parent 5db7226 commit 23f9873

File tree

6 files changed

+55
-7
lines changed

6 files changed

+55
-7
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
### LeetCode
2-
- 感觉自己菜的时候做两道题,无序
3-
- golang,题目详情在代码中有注释
4-
- 伤春岂我事,冷眼看花容!诸位共勉
1+
- 伤春岂我事,冷眼看花容!

problems201-250/231.power-of-two.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* 2的幂
2-
题目描述提示帮助提交记录社区讨论阅读解答
32
给定一个整数,编写一个函数来判断它是否是 2 的幂次方。
43
54
示例 1:

problems251-300/292.nim-game.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* 292. Nim游戏
2+
你和你的朋友,两个人一起玩 Nim游戏:桌子上有一堆石头,每次你们轮流拿掉 1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。你作为先手。
3+
4+
你们是聪明人,每一步都是最优解。 编写一个函数,来判断你是否可以在给定石头数量的情况下赢得游戏。
5+
6+
示例:
7+
8+
输入: 4
9+
输出: false
10+
解释: 如果堆中有 4 块石头,那么你永远不会赢得比赛;
11+
因为无论你拿走 1 块、2 块 还是 3 块石头,最后一块石头总是会被你的朋友拿走。 */
12+
func canWinNim(n int) bool {
13+
return n%4 != 0
14+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* 657. 机器人能否返回原点
2+
在二维平面上,有一个机器人从原点 (0, 0) 开始。给出它的移动顺序,判断这个机器人在完成移动后是否在 (0, 0) 处结束。
3+
4+
移动顺序由字符串表示。字符 move[i] 表示其第 i 次移动。机器人的有效动作有 R(右),L(左),U(上)和 D(下)。如果机器人在完成所有动作后返回原点,则返回 true。否则,返回 false。
5+
6+
注意:机器人“面朝”的方向无关紧要。 “R” 将始终使机器人向右移动一次,“L” 将始终向左移动等。此外,假设每次移动机器人的移动幅度相同。
7+
8+
9+
10+
示例 1:
11+
12+
输入: "UD"
13+
输出: true
14+
解释:机器人向上移动一次,然后向下移动一次。所有动作都具有相同的幅度,因此它最终回到它开始的原点。因此,我们返回 true。
15+
示例 2:
16+
17+
输入: "LL"
18+
输出: false
19+
解释:机器人向左移动两次。它最终位于原点的左侧,距原点有两次 “移动” 的距离。我们返回 false,因为它在移动结束时没有返回原点。 */
20+
func judgeCircle(moves string) bool {
21+
l, r, u, d := 0, 0, 0, 0
22+
for i := 0; i < len(moves); i++ {
23+
switch moves[i] {
24+
case 'L':
25+
l++
26+
case 'R':
27+
r++
28+
case 'U':
29+
u++
30+
case 'D':
31+
d++
32+
default:
33+
return false
34+
}
35+
}
36+
return l == r && u == d
37+
}
38+
// func judgeCircle(moves string) bool {
39+
// return strings.Count(moves,"R") == strings.Count(moves,"L") && strings.Count(moves,"U") == strings.Count(moves,"D")
40+
// }

prombles651-700/693.binary-number-with-alternating-bits.go renamed to problems651-700/693.binary-number-with-alternating-bits.go

File renamed without changes.

problems701-750/747.largest-number-at-least-twice-of-others.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import "fmt"
2-
31
/* 747. 至少是其他数字两倍的最大数
42
在一个给定的数组nums中,总是存在一个最大元素 。
53

0 commit comments

Comments
 (0)