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

herrDeng網內搜尋

自訂搜尋

Ads

2026年4月12日 星期日

黑柴犬與玩具tiger 1戰車

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.

黑柴犬走草山水圳AI動畫

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主要是其解法可針對更為廣義的題目,要快就用貪婪。

2026年2月28日 星期六

黑柴犬正在操作enigma密碼機

Py3 C++位元處理與DP解Leetcode 1680 Concatenation of Consecutive Binary Numbers


Py3 C++位元處理與DP解Leetcode 1680  Concatenation of Consecutive Binary Numbers
這當然不是DP的問題,但透過DP的手法卻可以大幅減少計算時間
----
This is certainly not a problem with dynamic programming (DP), but by using DP techniques, the computation time can be significantly reduced.
Related Posts Plugin for WordPress, Blogger...

熱門文章