Herr Deng桑的教學blog
這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
網頁
(移至...)
首頁
密碼學
程式設計Programming
APP
計算機概論
▼
2024年4月24日 星期三
C++ UnionFind BFS DFS解圖論問題Leetcode 1971 Find if Path Exists in Graph
›
C++ UnionFind BFS DFS解圖論問題Leetcode 1971 Find if Path Exists in Graph 使用UnionFind class實作容易,效能又好,這對無向圖特別有效。 為了比較,BFS、DFS也實作
Python C++速解Leetcode 1137 N th Tribonacci Number
›
Python CPP速解Leetcode 1137 N th Tribonacci Number 先用遞迴、再加上cache,然後轉成動態規劃,當然還可以用矩陣冪次方
2024年4月20日 星期六
C++ DFS BFS貪婪三法解Leetcode農地問題1992 Find All Groups of Farmland
›
C++ DFS BFS貪婪三法解Leetcode農地問題1992 Find All Groups of Farmland 採用三種方式解題,一是DFS, 二是BFS,前兩法都很標準。農地因為都是矩形,第三法採貪婪演算找出矩形右下角,簡單又快速。
2024年4月16日 星期二
C++ DFS BFS解二元樹Leetcode 623 Add One Row to Tree
›
C++ DFS BFS解二元樹Leetcode 623 Add One Row to Tree 要辨識一位程式設計師是否會使用常用的資料結構,binary tree就是個鑑別率高的東西,許多程式自學者壓根沒見過。Leetcode 623. Add One Row to Tr...
2024年4月14日 星期日
C++ python速解左葉節點之和Leetcode 404 Sum of Left Leaves
›
C++ python速解左葉節點之和Leetcode 404 Sum of Left Leaves。影片中採最簡易解法preorder走訪遞迴,並設參數isLeft=0,其他解法詳見Leetcode連結。Python解請進,C++提供一行解。
2024年4月12日 星期五
python c++用monotonic stack解 Leetcode難題42 trapping rain water並附pyplot繪直方圖解說
›
Python c++用monotonic stack解 Leetcode難題42 trapping rain water並附pyplot繪直方圖解說 想法是使用索引 m 的單調堆疊來找到右牆height[r]和左牆height [l];計算此區域高於底部 height[m]的...
2024年4月9日 星期二
Python C++速解Leetcode 2073 Time Needed to Buy Tickets
›
Python CPP速解LLeetcode 2073 Time Needed to Buy Tickets 假設x=tickets[k]。 當i≤k時,person[i]最多只能買x張票; 當 i大於k時,person[i]最多只能購買 x-1 票。python code請...
2024年4月7日 星期日
python C++DP動態規劃解Leetcode 678 Valid Parenthesis String
›
python C++DP動態規劃解Leetcode 678 Valid Parenthesis String 使用2D DP來求解。 由於 n≤100,因此帶有 memo 的遞迴可以完成這項工作。 知道了遞迴那麼DP就一定可行! 第二種方法是迭代 DP 程式碼; 使用 ...
2024年4月6日 星期六
python C++字串deque解Leetcode 1249 Minimum Remove to Make Valid Parentheses
›
python C++字串deque解Leetcode 1249 Minimum Remove to Make Valid Parentheses 連續幾天都是含括號的字串問題Leetcode 1249. Minimum Remove to Make Valid Parenthe...
2024年4月5日 星期五
python C++速解Leetcode 1544 make the string great
›
python C++速解Leetcode 1544 make the string great 基本上算是stack解法,但實作的語言C, C++, python只需要善用個別字串的特性,無須使用stack,大幅加快計算速度,C語言解答請進,並加上最佳C++解
‹
›
首頁
查看網路版