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

herrDeng網內搜尋

自訂搜尋

Ads

2023年10月2日 星期一

2023年9月25日 星期一

C++ Python用XOR sum解字串問題Leetcode 389 find the difference


C++ Python用XOR sum解字串問題Leetcode 389 find the difference。字串 t 是透過隨機打亂字串 s 產生的,然後在隨機位置再添加一個字母。找出那個添加的字母

2023年9月16日 星期六

C++ Dijkstra演算解爬山省力路徑Leetcode問題1631 Path With Minimum Effort


影片中的部份圖取自 wiki Dijkstra演算頁面。應該可以確認題目的「距離」是由所謂pseudo metric給定,這個要等檢查metric定義的條件時,才猛然發現。想通後,Union Find的解也解出,異常簡易。
[code on Leetcode]https://leetcode.com/problems/path-with-minimum-effort/solutions/4049711/c-dijkstra-s-algorithm-vs-dfs-binary-search-vs-union-find-pseudo-metric-91-ms-beats-98-93/

2023年9月3日 星期日

組合Pascal三角Python C++解Leetcode 62 unique paths


組合Pascal三角Python C++解Leetcode 62 unique paths。把網站的例題轉個45度角,它的計算方式就是Pascal三角,也就是組合數C^N_K  (N=n+m-2, K=m-1),程式要寫得好,還是要多學點數學!
有了遞迴公式,就可用動態規劃dynamic programming,動態規劃就是一種程式設計的技巧
Related Posts Plugin for WordPress, Blogger...

熱門文章