解Leetcode 451. Sort Characters By Frequency.兩個重點,一是可用陣列就不用hash table(C++ unordered_map)來計數,二是排序的元素很少,可以練習各種排序法,用sort,自製radix sort,用max heap(C++ priority_queue)
herrDeng網內搜尋
自訂搜尋
Ads
2024年2月7日 星期三
2024年2月6日 星期二
Python C++ hash table速解Leetcode 49 Group Anagrams
Python C++ hash table速解Leetcode 49 Group Anagrams
Leetcode今天是老題目49. Group Anagrams,解法很多種,不過弄清楚anagram就是排列,一個簡易又快速的解答就出爐了
2024年2月4日 星期日
C++ sliding window頻率計數陣列解Leetcode難題76 Minimum Window Substring打敗100趴
C++ sliding window頻率計數陣列解Leetcode難題76 Minimum Window Substring打敗100趴
難題Leetcode 76. Minimum Window Substring半年前就解出來了,不過解法不好,保持主要sliding window的架構,把unordered_map換成C int array,用點bitmask 就64個元素的陣列,先用C++,再用python於是100趴的code就成形了
訂閱:
意見 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
連續複利
-
請用Random產生20個0~99的奇數(可重複),然後排序
-
py3 cpp Line sweep解Leetcode 3346 Maximum Frequency of an Element After Performing Operations I 使用 line sweep不用排序,可得線性解 [Py3解請進]
-
Py3 C++計數bitmask與2 pointers速解Leetcode2273 Find Resultant Array After Removing Anagrams 字串長度最長也只有10,四個bits一組,用bitmask解題 ----- The maximum le...
-
輸入公元n年,輸出"平年" "閏年"
-
int a[]={21, 23, 57, 13 ,17, 6}; float average; average=?