herrDeng網內搜尋
自訂搜尋
Ads
2026年4月24日 星期五
2026年4月21日 星期二
C++UnionFind與陣列版Linked list解Leetcode 1722 Minimize Hamming Distance After Swap Operations
C++UnionFind與陣列版Linked list解Leetcode 1722 Minimize Hamming Distance After Swap Operations
真正的C++硬和解答,用 Union-Find解答Leetcode 1722. Minimize Hamming Distance After Swap Operations, 用兩個靜態陣列實作Linked List取代2D vector或是hash map
只要幾ms就run完了所有的testcases,當然是100%
-----
A true C++ hard-solution solution, using Union-Find to solve Leetcode 1722. Minimize Hamming Distance After Swap Operations, implementing a Linked List using two static arrays instead of a 2D vector or hash map. All test cases run in just a few milliseconds, achieving 100% completion.
[codes on Leetcode]https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations/solutions/8020783/unionfind-with-counting-freq31ms-beats-1-r1lw/
[C++ UnionFind BFS DFS解圖論問題Leetcode 1971 Find if Path Exists in Graph]https://www.youtube.com/watch?v=B1GQlUN08lk
2026年4月14日 星期二
RAG之NotebookLM操作DeckEdit解鎖文字與Keras辨識mnist手寫數字程式
RAG之NotebookLM操作DeckEdit解鎖文字與Keras辨識mnist手寫數字程式
解決NotebookLM產生簡報文字無法編輯的問題。
採用免費軟體DeckEdit解鎖文字
以Keras辨識mnist手寫數字程式為實際操作實例
2026年4月12日 星期日
Py3 C++ DP速解1320 Minimum Distance to Type a Word Using Two Fingers
Py3 C++ DP速解1320 Minimum Distance to Type a Word Using Two Fingers
這題確實有難度,最初的解答是3D DP,然後逐次化簡,化成2D後,大該就已經是極致了,不想用hash map,300x (26+1)也不大,0ms C++ code
-----
This problem is indeed challenging. The initial solution was 3D dynamic programming, which was then simplified to 2D, reaching its limit. I didn't want to use a hash map; 300x (26+1) isn't a large number. 0ms C++ code.
2026年4月6日 星期一
C++ unordered set PMR解Leetcode 874 Walking Robot Simulation
C++ unordered set PMR解Leetcode 874 Walking Robot Simulation
解Leetcode 874. Walking Robot Simulation因為constraints,只好用hashmap,C++ unordered_set是知名的慢,加上pmr可以快上幾倍
------
Solving LeetCode 874, Walking Robot Simulation, requires using a hashmap due to constraints. C++'s unordered_set is notoriously slow; adding PMR can speed it up several times.
2026年3月30日 星期一
2026年3月28日 星期六
C++UnionFind與matrix分析解難題Leetcode 2573 Find the String with LCP
解難題Leetcode 2573. Find the String with LCP,其實重點是lcp非常特殊的矩陣,只要搞定lcp各項的關聯,如對稱性,對角線上值-1等特性,應該能解出。會先用Union-Find主要是其解法可針對更為廣義的題目,要快就用貪婪。
訂閱:
文章 (Atom)
熱門文章
-
請用C/C++ 程式計算 S=1*1+2*2+3*3+4*4+.....+20*20=?
-
計算你的BMI
-
計算你上學期加權平均
-
算上學期加權平均
-
GCD(123456789,345634567)=?
-
33, 45, 87, 99, 27 算平均
-
test請留言! 到第十前,都沒說對!提示一下: 形態轉換int->float int sum=596; average=(double)sum/10; average=sum/10; 有何不同?
-
何謂演算法?並列出一無窮迴圈的範例!
-
55x+27y=gcd