Plan:

每天做13道 LeetCode-75 (https://leetcode.com/studyplan/leetcode-75/)

然后研读Top Interview 150的答案 (https://leetcode.com/studyplan/top-interview-150/).



Day 1 - Sep. 10

同时遍历dict的key和value:

```python
d = {"a": 1, "b": 2, "c": 3}

for k, v in d.items():
    print(k, v)
    
# 按 key 从大到小
for k, v in sorted(d.items(), key=lambda x: x[0], reverse=True):
    print(k, v)
    
# 按 value 从大到小
for k, v in sorted(d.items(), key=lambda x: x[1], reverse=True):
    print(k, v)
```

字符串和列表互转

```python
s = "hello"
lst = list(s)
print(lst)  
# ['h', 'e', 'l', 'l', 'o']

lst = ['h', 'e', 'l', 'l', 'o']
s = ''.join(lst)
print(s)
# hello
```



Day 2 - Sep. 11

Set的集合操作

```python
s = set()
s.add(4)
print(s)  # {4}

# .intersection()

a = {1, 2, 3, 4}
b = {3, 4, 5, 6}

result = a.intersection(b)
print(result)  # 输出: {3, 4}

# .difference()

a = {1, 2, 3, 4}
b = {3, 4, 5, 6}

result = a.difference(b)
print(result)  # 输出: {1, 2}

```

Python的内置queue:

```python
# deque
from collections import deque

dq = deque()
dq.append(1)       # 队尾入队
dq.append(2)
print(dq.popleft())  # 队首出队，输出 1

# list
dq = []
dq.append(1)        
dq.append(2)
dq.pop(0)  # 队首出队
```

Python的内置stack:

```python
# deque
from collections import deque

dq = deque()
dq.append(1)       # 队尾入队
dq.append(2)
print(dq.pop())  # 队尾出队，输出 2

# list
dq = []
dq.append(1)        
dq.append(2)
dq.pop()  # 队尾出队
```

