Skip to content

Commit 30b3f32

Browse files
committed
update readme and dp
1 parent 9980417 commit 30b3f32

7 files changed

Lines changed: 88 additions & 0 deletions

File tree

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,70 @@
22

33
Minimal and clean examples of data structures and algorithms.
44

5+
List of Implementations:
6+
7+
```
8+
.
9+
├── array
10+
│   ├── house_robber.py
11+
│   └── longest_increasing_subsequence.py
12+
├── builtins
13+
│   ├── dictionary.py
14+
│   ├── list.py
15+
│   ├── set.py
16+
│   └── tuple.py
17+
├── dynamic_programming
18+
│   └── max_subarray.py
19+
├── graph
20+
│   ├── find_path.py
21+
│   ├── graph.py
22+
│   └── traversal.py
23+
├── hashtable
24+
│   └── hashtable.py
25+
├── linkedlist
26+
│   ├── first_cyclic_node.py
27+
│   ├── kth_to_last.py
28+
│   ├── linkedlist.py
29+
│   └── remove_duplicates.py
30+
├── matrix
31+
│   └── matrix_rotation.txt
32+
├── output.txt
33+
├── queue
34+
│   └── queue.py
35+
├── search
36+
│   ├── binary_search.py
37+
│   ├── count_elem.py
38+
│   ├── first_occurance.py
39+
│   └── last_occurance.py
40+
├── sorting
41+
│   ├── insertion_sort.py
42+
│   ├── merge_sort.py
43+
│   ├── quick_sort.py
44+
│   └── selection_sort.py
45+
├── stack
46+
│   ├── __init__.py
47+
│   ├── __init__.pyc
48+
│   ├── stack.py
49+
│   └── stack.pyc
50+
├── string
51+
│   ├── license_number.py
52+
│   ├── reverse_string.py
53+
│   ├── reverse_vowel.py
54+
│   └── reverse_words.py
55+
├── testStack.py
56+
└── tree
57+
├── bintree2list.py
58+
├── deepest_left.py
59+
├── invert_tree.py
60+
├── longest_abs_path.py
61+
├── max_height.py
62+
├── predecessor.py
63+
├── same_tree.py
64+
├── successor.py
65+
├── tree.py
66+
└── trie.py
67+
68+
69+
70+
```
571

array/house_robber.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def house_robber(houses):
2+
last, now = 0, 0
3+
for house in houses:
4+
tmp = now
5+
now = max(last + house, now)
6+
last = tmp
7+
return now
8+
9+
houses = [1, 2, 16, 3, 15, 3, 12, 1]
10+
11+
print(house_robber(houses))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
def max_subarray(array):
3+
max_so_far = max_now = array[0]
4+
for i in range(1, len(array)):
5+
max_now = max(array[i], max_now + array[i])
6+
max_so_far = max(max_so_far, max_now)
7+
return max_so_far
8+
9+
a = [1, 2, -3, 4, 5, -7, 23]
10+
print(a)
11+
print(max_subarray(a))

0 commit comments

Comments
 (0)