Leetcode問題1642. Furthest Building You Can Reach也是用Greedy演算,有梯子、有磚塊,要訣就是高度差大的用梯子,高度差小的用磚塊,至於容器,C++可用priority_queue或用make_heap,當然也可用multiset,用heap的解答當然很快速,千萬不要誤入歧途採用DP動態規劃,先看constraints就知。
herrDeng網內搜尋
自訂搜尋
Ads
2024年2月17日 星期六
2024年2月15日 星期四
C++, python貪婪演算解多邊形問題Leetcode 2971 Find Polygon With the Largest Perimeter
C++, python貪婪演算解多邊形問題Leetcode 2971 Find Polygon With the Largest Perimeter
程式實作不難,用貪婪演算即可,有人知其然不知所以然,貪婪演算是否可用是需要數學證明的,下面有一個用make_heap的解答,保留在此
2024年2月13日 星期二
C, C++ ,python速解迴文Leetcode 2108 Find First Palindromic String in the Array
C C++ python速解迴文Leetcode 2108 Find First Palindromic String in the Array
這就是迴文「花蓮噴水池水噴蓮花」"racecar",Leetcode蒐集了一堆跟迴文有關的問題,應該是說科技公司面試常出迴文問題。想看C語言解答請進
2024年2月11日 星期日
訂閱:
意見 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
連續複利
-
py3 cpp Line sweep解Leetcode 3346 Maximum Frequency of an Element After Performing Operations I 使用 line sweep不用排序,可得線性解 [Py3解請進]
-
請用Random產生20個0~99的奇數(可重複),然後排序
-
C++ py3 C Rust adjacent difference與loop速解Leetcode 1526 Minimum Number of Increments on Subarrays to Form a Target Array [Py3一行解請進]
-
int a[]={21, 23, 57, 13 ,17, 6}; float average; average=?
-
輸入公元n年,輸出"平年" "閏年"
-
Py3 C++導出遞迴公式解難題Leetcode1611 Minimum One Bit Operations to Make Integers Zero從導出公式到寫出code,一次完成解Leetcode難題 [C++一行解請進]
