/* 自定義代碼塊樣式 */

herrDeng網內搜尋

自訂搜尋

Ads

2024年1月25日 星期四

python C++遞迴邁向dp動態規劃解Leetcode 1143 Longest Common Subsequence


python C++遞迴邁向dp動態規劃解Leetcode 1143  Longest Common Subsequence. LCS之類的問題其實跟 DNA 序列的比對問題密切關聯。非常經典的DP動態規劃問題,有的人會TLE,請注意不是只設cache就好,尤其是C++,字串不要call-by-value 

2024年1月20日 星期六

C++ python DP動態規劃與monotonic stack單調堆疊解Leetcode 907 Sum of Subarray Mini...


解Leetcode 907. Sum of Subarray Minimums,用了DP動態規劃以及Monotonic stack,可以得到線性時間解,如果直接解,那可是O(n^3)時間,有好方法當然要會用

2024年1月13日 星期六

python C++速解Leetcode 1347 Minimum Number of Steps to Make Two Strings A...


python cpp速解Leetcode 1347  Minimum Number of Steps to Make Two Strings Anagram
No need for hash table. there are are just 26 alphabets.
s is anagram of t  ⟺ freq(s)==freq(t)
In other words, s is a permutation of t.

2024年1月8日 星期一

Python C++解二元搜尋樹問題Leetcode 938 Range Sum of BST


Python C++解二元搜尋樹問題Leetcode 938  Range Sum of BST。其實這是蠻典型二元收尋樹的問題,可以試著使用preorder, postorder & inorder等不同走訪的方式來解,二元收尋樹是資料結構的內容,會用它來寫程式跟不會用,就有顯著的區隔。

2023年12月31日 星期日

Python C++速解Leetcode 1624 Largest Substring Between Two Equal Characters


Python C++速解Leetcode 1624 Largest Substring Between Two Equal Characters。2023年底是簡單題Leetcode 1624. Largest Substring Between Two Equal Characters,無需Hash table,用array才是王道
Related Posts Plugin for WordPress, Blogger...

熱門文章