各類型題需要記住的東西
1. 數組
- 注意常用的導入方法(類字典)
from collections import Counter
dict = Counter(x)- python自帶排序 — 逆序 多個關鍵字
list.sort(reverse=True, key=lambda x:(x[0],x[1]))
2. 字符串
- 也可以用#數組#的Counter的當如方法
- 以什麼字符開始:j.startswith(res) 結束類似 endswith
- 注意字符串各大方法 需要返回結果
3. 鏈表
- 注意他的結構
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
4. 樹
- 注意他的結構
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None