Greedy common problems

Greedy common problems of "starting from 0 to make LeetCode"

1. Prefix tree (trie-tree)
·
Insert picture description here
Add prefix tree function
Insert picture description here

2. Greedy: How can the largest string of N strings be combined?

Insert picture description here
ab<ba,bc<cb => ac<ca

3. Greed: The least costly
Insert picture description here
Huffman coding problem.
Try to make every cut as close as possible on both sides, greedy and greedy,
greedy strategy without proof
Insert picture description here
Insert picture description here

4. Greedy: The most profitable
Insert picture description here
heap, which is the priority queue Insert picture description here
heap + comparator, generates a small root heap, a large root heap
Insert picture description here
Insert picture description here
Insert picture description here

5. There is one more question, which I talked about before when talking about stacking
Insert picture description here

6. Greedy: The most number of sessions. Greedy
Insert picture description here
at the start time. Greedy
at the short duration. Greedy
at the end time.
Insert picture description here

Guess you like

Origin blog.csdn.net/bosszhao20190517/article/details/107878809