解難題Leetcode 2573. Find the String with LCP,其實重點是lcp非常特殊的矩陣,只要搞定lcp各項的關聯,如對稱性,對角線上值-1等特性,應該能解出。會先用Union-Find主要是其解法可針對更為廣義的題目,要快就用貪婪。
herrDeng網內搜尋
自訂搜尋
Ads
2026年3月28日 星期六
2026年3月23日 星期一
2026年2月28日 星期六
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.
2026年2月21日 星期六
C++ Py3 bitmask速解Leetcode 762 Prime Number of Set Bits in Binary Representation
C++ Py3 bitmask速解Leetcode 762 Prime Number of Set Bits in Binary Representation
這段影片示範如何使用計數位元和位元遮罩(bit mask),用幾行程式碼解決這個問題。
-----
this video shows how to use count bits & bitmask to solve this question in few lines.
2026年2月19日 星期四
Py3 C++迴圈與計數解Leetcode 696 Count Binary Substrings
Py3 C++迴圈與計數解Leetcode 696 Count Binary Substrings
Leetcode 696. Count Binary Substrings雖然標示為easy,也沒那麼trivial,花了一番功夫才解出branchless C++。而一般回圈解倒是不難,但須要思考一下
-----
Leetcode 696. Count Binary Substrings, though marked as easy, isn't exactly trivial; it took me some effort to solve it in branchless C++. Solving the general loop problem isn't difficult, but it needs thinking.
2026年2月13日 星期五
Py3 C++使用 4 hashmaps解Leetcode 3714 Longest Balanced Substring II
不喜歡C++的unordered_map,主要的原因是慢,也不想重新刻一個好的hashmap,不過透過memory_resource中的工具,加快三倍速度,也能寫出簡易的beats 99%C++解答
2026年2月4日 星期三
py3 C++巢狀迴圈解Leetcode難題3640 Trionic Array II
py3 CPP巢狀迴圈解Leetcode難題3640 Trionic Array II
使用巢狀迴圈來解決 LeetCode 上的難題,就用類似解決簡單的題目的方法。
Lettcode 3637. Trionic Array I簡單問題解了,困難的類似題3640. Trionic Array II也用類似方法解了。不要小看怎麼用迴圈
2026年2月1日 星期日
C++ Py3用nth_element, nsmallest解Leetcode 3010 Divide an Array Into Subar...
C++ Py3用nth_element, nsmallest解Leetcode 3010 Divide an Array Into Subarrays With Minimum Cost I
問題簡單,但應該是同類問題入門,先提供幾個簡易解答
[Py3一行解請進]
----
訂閱:
文章 (Atom)
熱門文章
-
C++用 -1 mask法達到branchless解Leetcode1513 Number of Substrings With Only 1s|Py3 1-liner 其實很容易,想練功,試試一行解,或是把if分岔拿掉 [C++無分岔解請進]
-
請問你所使的電腦,CPU的規格 Cache多大?其他硬體配置...... 另外, "INTEL® XEON PHI™ 處理器 7230F"的大致規格為?
-
問int怎麼存-689這個數字。 int用4個bytes。 答案請用16進位表達。
-
計算你上學期加權平均
-
請用C/C++ 程式計算 S=1*1+2*2+3*3+4*4+.....+20*20=?
-
何謂演算法?並列出一無窮迴圈的範例!
-
將費氏數列輸出至一long 陣列 其中f[0]=1, f[1]=2, f[n]=f[n-1]+f[n-2] (n>=2)
-
請用CPU-Z軟體檢測Cache & Memory 註:快取(L1-L3: SRAM) 第一級快取(L1)–通常存取只需要幾個週期,通常是幾十個KB。 第二級快取(L2)–比L1約有2到10倍較高延遲性,通常是幾百個KB或更多。 第三級快取(L3)(不...
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
