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

herrDeng網內搜尋

自訂搜尋

Ads

顯示具有 程式設計[視訊] 標籤的文章。 顯示所有文章
顯示具有 程式設計[視訊] 標籤的文章。 顯示所有文章

2026年9月4日 星期五

0ms C++ Py3 |Suffix MIN與Prefix MAX解Leetcode 3903, 3904 Smallest Stable Index


0ms C++ Py3 Suffix MIN與Prefix MAX解Leetcode 3903, 3904  Smallest Stable Index
使用一個名為 suf 的陣列來記錄字尾最小值(suffix min)。
接著進行動態Prefix MAX(字首最大值)的計算,以找出何時滿足Max-suf[i] leq k!
[Py3  code請進]

2026年9月2日 星期三

0ms C++ 1-line Py3解Leetcode 3875, 3876 Construct Uniform Parity Array


0ms C++ 1-line Py3解Leetcode 3875, 3876  Construct Uniform Parity Array
一次解Leetcode 3875, 3876,code很簡單,重點是邏輯。
Solving LeetCode 3875 & 3876 together. Simple code, focus is on the logic.

2026年8月28日 星期五

0ms |C++貪婪mask dp解Leetcode難題3734 Lexico min Palindrome greater then target


0ms |C++貪婪mask dp解Leetcode難題3734 Lexico min Palindrome greater then target
這部影片詳細解析了 LeetCode 3734 難題。我們將結合「貪婪演算法 (Greedy)」與「位元遮罩動態規劃 (Bitmask DP)」技術,目標是找出比給定字串大、且字典序最小的回文字串。影片中展示了如何透過剪枝與狀態壓縮將效能優化至 0ms,達成最速解。適合想挑戰高難度演算法與 C++ 實作技巧的開發者。

2026年8月20日 星期四

0ms Branchless Leetcode 3069 | Py3 & C++ 高速解法


Py3 CPP 速解3069  Distribute Elements Into Two Arrays I
為什麼要寫branchless code?避免 CPU 的分支預測失敗!當代CPU 會預先猜測條件判斷(如 if-else)的結果並繼續往下執行。當預測成功時,猜對了效能極佳,猜錯了會造成時間上的懲罰。利用容器index的True or False達成Branchless code!
[C++ Python3 codes請進]

2026年8月15日 星期六

0ms C++ Py3 1 line 解 Leetcode 3702 sequence With Non Zero Bitwise XOR


0ms C++ Py3 1 line 解 Leetcode 3702  sequence With Non Zero Bitwise XOR
迴圈解不稀奇,Python一行解也不稀奇,C++一行解就很少了!
[C++ Py3 一行解請進 👇]

2026年8月12日 星期三

C++ Py3|Sliding window hashmap解Leetcode 2958 Length of Longest Subarray With at Most K


Beat 99.89% C++ Py3|Sliding window hashmap解Leetcode 2958 Length of Longest Subarray With at Most K
一陣子沒出Leetcode解題長片。這題其實很標準2958. Length of Longest Subarray With at Most K Frequency,適合練習sliding window+ hash map ! 客製化的hash map似乎是overkilling

2026年8月8日 星期六

2026年7月27日 星期一

0ms 速解Leetcode 1464 最大的乘積:別只會用 Sort!試試Py nlargest, C++ nth_element


0ms|1 line Py3 #nlargest #cpp #nth_element 速解 #Leetcode1464 最大的乘積
Python 1行解用heapq.nlargest。C++2行解用nth_element,都是linear 0ms
[C++, Py3 codes請進]

2026年7月25日 星期六

2026年7月2日 星期四

LeetCode 3286: 別只用 Dijkstra!0-1 BFS (deque) 才是 0ms 關鍵


0ms |C++ Py3| BFS使用deque解Leetcode 3286  Find a Safe Walk Through a Grid
了解以下幾點有助於解決最短路徑問題:
所有權重相同時,只需使用基於佇列queue的廣度優先搜尋(BFS over queue)
權重有兩種非負值(如本題所示),使用基於雙端佇列(deque)的廣度優先搜尋(BFS over deque)
權重為正值時,使用基於優先權佇列(priority queue)的廣度優先搜尋(類似Dijkstra演算法)

2026年7月1日 星期三

Beats 100%|C++ UnionFind BFS解Leetcode 2812 Find the Safest Path in a Grid


Beats 100%|C++ unionFind BFS linkedList解Leetcode 2812  Find the Safest Path in a Grid
本影片詳細講解如何結合 UnionFind與 BFS(廣度優先搜尋)來解決 LeetCode 2812. Find the Safest Path in a Grid。透過 BFS 預處理所有格子到最近小偷的距離,再利用 UnionFind 找出具有最大安全性係數的路徑,最終在 C++ 實作中達到 182ms 並擊敗 100% 的紀錄!

2026年6月27日 星期六

C++ bitset array依數字 3、13、177、31622分割解Leetcode 3020 Find the Maximum Number of Elements in Subset


C++ bitset array依數字 3、13、177、31622分割解Leetcode 3020  Find the Maximum Number of Elements in Subset
不用hashmap,另圖蹊徑才有辦法快速解答Leetcode 3020. 
-----
No Hashmap—forging a new path to crush LeetCode 3020 fast.
Trick: isqrt(1e9)=31622 , 177, 13,  3
 #anwendeng 

2026年6月24日 星期三

Beats 100%|C/C++矩陣冪次方解Leetcode難題3700 Number of ZigZag Arrays II


Beats 100%|C/C++矩陣冪次方解Leetcode難題3700  Number of ZigZag Arrays II
在這段影片中,我將深入解析如何使用 矩陣快速冪 (Matrix Exponentiation) 來高效解決 LeetCode 難題 3700:Number of ZigZag Arrays II。這題是 ZigZag Array 系列的進階版本,對時間複雜度有極高要求。

2026年6月18日 星期四

LeetCode 1344 分針時針夾角:0ms 一行秒殺 (C++/Python)


0ms| 1-liner C++ Py3|1344. Angle Between Hands of a Clock
應徵程式設計師,也會問小學數學,不用懷疑。
-----
When applying for a programmer position, they'll ask you elementary school math questions, no doubt about it.

#leetcode #1liner  #cplusplus  #python #leetcode1344
[Py3 1-liner請進]
Related Posts Plugin for WordPress, Blogger...

熱門文章