/* 自定義代碼塊樣式 */
Herr Deng桑的教學blog
這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
網頁
首頁
密碼學
程式設計Programming
APP
計算機概論
herrDeng網內搜尋
自訂搜尋
Ads
2024年9月3日 星期二
python C++速解Leetcode 1945 Sum of Digits of String After Convert
python C++速解Leetcode 1945 Sum of Digits of String After Convert
這是個簡單問題,有技巧。
第一次轉換不需要用bigINT來存,只是將數字與第1輪的數字相加即可。
由於s.length最多可能為100,因此使用bigInt或其他字串效率非常低。
[Python code請進]
---
按我讀文 »
2024年8月23日 星期五
C++ stringstream解分數加減Leetcode 592 Fraction Addition and Subtraction
C++ stringstream解分數加減Leetcode 592 Fraction Addition and Subtraction
程式設計分數加減很難嗎?計算容易,但處理字串費事,用stringstream就簡單了
按我讀文 »
2024年8月17日 星期六
C++ DP動態規劃解Leetcode 937 Maximum Number of Points with Cost
C++ DP動態規劃解Leetcode 937 Maximum Number of Points with Cost
有些標示medium要比標示hard的問題還要難,Leetcode 1937. Maximum Number of Points with Cost,DP動態規劃可解,但怎麼樣的遞迴關係才能降低時間複雜度?
[Python解請進]
----------
按我讀文 »
2024年8月15日 星期四
python C++ Greedy速解找零問題Leetcode 860 Lemonade Change
python C++ Greedy速解找零問題Leetcode 860 Lemonade Change
b=20時貪婪演算法保持檢查順序,先找十塊,不要改變檢查順序,否則不起作用
[python解請進]
-----
按我讀文 »
2024年8月10日 星期六
C++ EULER特徵數定理與UnionFind解Leetcode959 Regions Cut By Slashes
EULER特徵數定理與UnionFind解Leetcode959 Regions Cut By Slashes
EULER特徵數定理:平面連通圖有V-E+F
--------------
按我讀文 »
2024年8月9日 星期五
Python C++解魔方陣Leetcode 840 Magic Squares In Grid
Python C++解魔方陣Leetcode 840 Magic Squares In Grid.
影片一開始就是展示如何解一個3x3的魔方陣,5總是在中心
In the beginning of film is to show how to solve a 3x3 magic square, 5 is always in the center.
按我讀文 »
2024年8月2日 星期五
Python C++ sliding windows解Leetcode 2134 Minimum Swaps to Group All 1'...
Python C++ sliding windows解Leetcode 2134 Minimum Swaps to Group All 1's Together II
使用sliding window, 由於陣列是循環的,所以右邊的游標r應該一直走到n+n0或n+n1
[Python code請進]
-----
按我讀文 »
2024年7月26日 星期五
C++Floyd Warshall解Leetcode 1334 Find the City With the Smallest Number ...
C++Floyd Warshall解Leetcode 1334 Find the City With the Smallest Number of Neighbors at a Threshold
由於每對 (i, j) 都有許多最短路徑需要計算,採用 Floyd-Warshall 演算法比較划算。
---
按我讀文 »
2024年7月24日 星期三
Python C++速解排序問題Leetcode 2191 Sort the Jumbled Numbers
今日Leetcode的排序問題2191. Sort the Jumbled Numbers,主要有兩個部份,一個是把數字轉成另一個數字,用int就行,採Least Significant Digit First。然後排序,不建議用自訂Lambda,跑能過但非常慢;更不建議自製車輪去排序。比較快的方式是sort ((mapping(x), index),然後再從排序後的資料中取得 x
[Python code請進]
按我讀文 »
2024年7月20日 星期六
Python C++採Greedy 2 pointers解Leetcode 1605 Find Valid Matrix Given Row ...
Python CPP採Greedy 2pointers解Leetcode 1605 Find Valid Matrix Given Row and Column Sums
將大小為 r*c 的陣列 arr 初始化為全 0
獨立的 i、j 是 2 個指標。使用迴圈繼續
設 x=min(rowSum[i], colSum[j])
設定 arr[i][j]=x & rowSum[i]-=x, colSum[j]-=x 根據 rowSum[i]==0 & colSum[j]==0 移動 i, j。
[Python解請進]
----
按我讀文 »
較新的文章
較舊的文章
首頁
訂閱:
文章 (Atom)
熱門文章
C++用 -1 mask法達到branchless解Leetcode1513 Number of Substrings With Only 1...
C++用 -1 mask法達到branchless解Leetcode1513 Number of Substrings With Only 1s|Py3 1-liner 其實很容易,想練功,試試一行解,或是把if分岔拿掉 [C++無分岔解請進]
簡易程式2(平方和)
請用C/C++ 程式計算 S=1*1+2*2+3*3+4*4+.....+20*20=?
計算你的BMI
計算你的BMI
計算你上學期加權平均
計算你上學期加權平均
何謂public-key密碼系統?....
何謂public-key密碼系統? 何謂secret-key密碼系統? 各列舉五種!
算上學期加權平均
算上學期加權平均
GCD
GCD(123456789,345634567)=?
test
test請留言! 到第十前,都沒說對!提示一下: 形態轉換int->float int sum=596; average=(double)sum/10; average=sum/10; 有何不同?
何謂演算法
何謂演算法?並列出一無窮迴圈的範例!
Ex5 請問int怎麼存-689這個數字
問int怎麼存-689這個數字。 int用4個bytes。 答案請用16進位表達。