Skip to content

Commit f1b2365

Browse files
committed
fix bug
1 parent f24abcc commit f1b2365

File tree

4 files changed

+6
-237
lines changed

4 files changed

+6
-237
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ This command specifies the `english` branch and limit the depth of clone, get ri
8181
* [What is DP Optimal Substructure](dynamic_programming/OptimalSubstructure.md)
8282
* [Longest Increasing Subsequence](dynamic_programming/LongestIncreasingSubsequence.md)
8383
* [KMP Algorithm In Detail](dynamic_programming/KMPCharacterMatchingAlgorithmInDynamicProgramming.md)
84+
* [House Robber Series](dynamic_programming/HouseRobber.md)
8485
* [动态规划详解](dynamic_programming/动态规划详解进阶.md)
8586
* [团灭 LeetCode 股票买卖问题](dynamic_programming/团灭股票问题.md)
86-
* [House Robber Series](dynamic_programming/HouseRobber.md)
8787

8888
* V. Common Knowledge
8989
* [Difference Between Process and Thread in Linux](common_knowledge/linuxProcess.md)

SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
* [What is DP Optimal Substructure](dynamic_programming/OptimalSubstructure.md)
6969
* [Longest Increasing Subsequence](dynamic_programming/LongestIncreasingSubsequence.md)
7070
* [KMP Algorithm In Detail](dynamic_programming/KMPCharacterMatchingAlgorithmInDynamicProgramming.md)
71+
* [House Robber Problems](dynamic_programming/HouseRobber.md)
7172
* [动态规划详解](dynamic_programming/动态规划详解进阶.md)
7273
* [团灭 LeetCode 股票买卖问题](dynamic_programming/团灭股票问题.md)
73-
* [团灭 LeetCode 打家劫舍问题](dynamic_programming/抢房子.md)
7474

7575
* V. Common Knowledge
7676
* [Difference Between Process and Thread in Linux](common_knowledge/linuxProcess.md)

dynamic_programming/抢房子.md

Lines changed: 0 additions & 231 deletions
This file was deleted.

interview/one-line-code-puzzles.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ For instance, `piles=[2, 1, 9, 5]`, you take first, you can choose 2 or 5 and yo
5252
5353
Finally, your opponent has no choice but choosing 1.
5454
55-
In summary, you get $2 + 9 = 11$ stones in total, your opponents gets $5 + 1 = 6$ stones. You win, the return value is true.
55+
In summary, you get `2 + 9 = 11` stones in total, your opponents gets `5 + 1 = 6` stones. You win, the return value is true.
5656
5757
As you can see that it is not always correct to choose the one with larger number of stones. Why you should choose 2 rather than 5 at the first time? Because 9 is behind 5. You will lose the game for giving the pile of 9 stones to the opponent for chasing a moment's gain.
5858
@@ -104,15 +104,15 @@ First, because the lights are always off at the beginning, a certain light must
104104

105105
Let's say we only have six lights, and we're only looking at the sixth light and it's going to take six turns, right? How many times is the switch going to be pressed for the sixth light? It's not difficult to see that its switch will be pressed at the 1st, 2nd, 3rd and 6th round.
106106

107-
Why the light will be flipped at these rounds? Because $6=1\times6=2\times3$. In general, the factors come in pairs, which means that the number of times the switch is pressed is usually even, but in a special case, if there are 16 lights, how many times will the 16th light be flipped?
107+
Why the light will be flipped at these rounds? Because `6=1*6=2*3`. In general, the factors come in pairs, which means that the number of times the switch is pressed is usually even, but in a special case, if there are 16 lights, how many times will the 16th light be flipped?
108108

109-
$16=1\times16=2\times8=4\times4$
109+
`16=1*16=2*8=4*4`
110110

111111
The factor 4 repeats, so the 16th light will be flipped 5 times which is odd, and now you understand the relationships to the square root, right?
112112

113113
But, we're going to figure out how many lights are on at the end, and what does that mean by square root? Just think about it a little bit.
114114

115-
Suppose we have 16 lights, and we take the square root of 16, which is equal to 4, and that means we're going to end up with 4 lights on. The lights are $1\times1=1$, $2\times2=4$, $3\times3=9$, and $4\times4=16$.
115+
Suppose we have 16 lights, and we take the square root of 16, which is equal to 4, and that means we're going to end up with 4 lights on. The lights are `1*1=1`, `2*2=4`, `3*3=9`, and `4*4=16`.
116116

117117
Some square root of n turns out to be a decimal. However, converting them to integers is the same thing as getting all the integers smaller than a certain integer upper bound, and the square roots of these numbers are the index of the lights on at last. so just turn the square root into an integer, that's the answer to the question.
118118

0 commit comments

Comments
 (0)