/* 自定義代碼塊樣式 */
Herr Deng桑的教學blog
這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
網頁
首頁
密碼學
程式設計Programming
APP
計算機概論
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來排序,左有兩游標大小一對看能不能一次載兩人,逐次移動游標
-------
按我讀文 »
2024年5月1日 星期三
如何將teachable Machine訓練好的模型在Google colab執行python opencv程式
如何將teachable Machine訓練好的模型在Google colab執行python opencv程式
按我讀文 »
2024年4月29日 星期一
C++/reroot DP動態規劃解Leetcode難題834 Sum of Distances in Tree
C++/reroot DP動態規劃解Leetcode難題834 Sum of Distances in Tree
關鍵字:reroot DP。 你會發現很多關於它的討論。
對於作為根的每個節點,進行 DFS,將獲得 O(n^2) 的解決方案,但可能 TLE。
使用一次遞迴 DFS 求 root=0 的樹中的距離和,計算每個節點 i 作為根的子樹中的節點數。
按我讀文 »
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 Tree是個好練習
按我讀文 »
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]的水量應為min(height[r]-height[m], height[l]-height[m])*(r-l-1)
按我讀文 »
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請進
按我讀文 »
較新的文章
較舊的文章
首頁
訂閱:
文章 (Atom)
熱門文章
河內塔程式
河內塔程式
費氏數列
將費氏數列輸出至一long 陣列 其中f[0]=1, f[1]=2, f[n]=f[n-1]+f[n-2] (n>=2)
統計2
統計第一作業 2, 3, 8, 9
array
array ex 1, 2,3,7,8
Fibonacci Sequence(1)
Fibonacci sequence: a[0]=1, a[1]=1, a[2]=2, a[3]=3, a[4]=5,...... In general, a[n]=1 as n=0,1, a[n]=a[n-1]+a[n-2] as n>=2. Use this...
算上學期加權平均
算上學期加權平均
出生率
任何一個國家任一時段連續5年的出生率統計
輸出字串20次
輸出字串20次
「全民資安素養自我評量」
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
簡答題
簡答題: 比較C/C++, Java, VB的差異!