herrDeng網內搜尋

自訂搜尋

Ads

2024年5月4日 星期六

C++ python貪婪排序2 pointer解Leetcode 881 Boats to Save People


C++ python貪婪排序2 pointer解Leetcode 881  Boats to Save People
Greedy是這類問題的關鍵,片中先用sort, counting sort來排序,左有兩游標大小一對看能不能一次載兩人,逐次移動游標
-------
Greedy is the key to this kind of problem. In the film, sort and counting sort are first used to sort. There are two pointers left & right, take one big and one small. See if you can take 2 people in a boat or not, move the pointers

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章