Skip to content

Commit 9bcbf36

Browse files
committed
add rob doc
1 parent 05bc79e commit 9bcbf36

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

house-robber/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Rob or not
2+
3+
assume that there are 9 houses along the street
4+
and you have a `rob` func can tell you the how much money you can get from first 8 hourses.
5+
6+
7+
what about the 9th house
8+
9+
```
10+
? = not sure
11+
* = must rob
12+
_ = must not rob
13+
14+
rob
15+
16+
[? ? ? ? ? ? ? ?] _ *
17+
[0 1 2 3 4 5 6 7] 8 9
18+
19+
money = rob(0..7) + house_value[9]
20+
21+
or not
22+
23+
[? ? ? ? ? ? ? ? ?] _
24+
[0 1 2 3 4 5 6 7 8] 9
25+
26+
money = rob(0..8)
27+
28+
29+
rob(0..9) = max(rob(0..8), rob(0..7) + house_value[9])
30+
```
31+
32+
then it is easy to write a `rob(0..n)`
33+

0 commit comments

Comments
 (0)