python nsmallest與C++ nth_element解巧克力Leetcode2706 Buy Two Chocolates
herrDeng網內搜尋
自訂搜尋
Ads
2023年12月20日 星期三
2023年12月18日 星期一
2023年12月16日 星期六
Python C++秒搞定Leetcode 242 Valid Anagram
Python C++秒搞定Leetcode 242 Valid Anagram。其實解這問題C++, Python都有1 line code,有興趣者請進:
2023年12月13日 星期三
2023年12月11日 星期一
C++ python binary search二元搜尋解Leetcode1287 Element Appearing More Than...
C++ python binary search二元搜尋解Leetcode1287 Element Appearing More Than 25% In Sorted Array。程式不難找到合用的套件就好,要會用C++的upper_bound, lower_bound或是python的bisect.bisect_right, bisect.bisect_left
2023年12月10日 星期日
2023年12月6日 星期三
Python C++等差數列解Leetcode1716 Calculate Money in Leetcode Bank
等差數列(Arithmetic sequence)絕對是基礎數學,Leetcode1716 Calculate Money in Leetcode Bank這題當然是用O(1)時間的解答方式。
2023年12月4日 星期一
C, python解leetcode 2264 Largest 3 Same Digit Number in String
Leetcode又是連續出數日簡單的問題2264. Largest 3-Same-Digit Number in String,然而簡單問題還要要用適當的方式來解,解法最好有延展性,就用類似sliding window的解法。
2023年12月2日 星期六
2023年11月25日 星期六
C++ Python公式推導Prefix sum解Leetcode 1685 Sum of Absolute Differences in a...
C++ Python公式推導Prefix sum解Leetcode 1685 Sum of Absolute Differences in a Sorted Array
對於會用Σ處理公式的,Leetcode 1685. Sum of Absolute Differences in a Sorted Array這應算是Bill Gates口中簡單的數學,
訂閱:
文章 (Atom)
熱門文章
-
C++用 -1 mask法達到branchless解Leetcode1513 Number of Substrings With Only 1s|Py3 1-liner 其實很容易,想練功,試試一行解,或是把if分岔拿掉 [C++無分岔解請進]
-
請用C/C++ 程式計算 S=1*1+2*2+3*3+4*4+.....+20*20=?
-
計算你的BMI
-
計算你上學期加權平均
-
GCD(123456789,345634567)=?
-
算上學期加權平均
-
何謂演算法?並列出一無窮迴圈的範例!
-
33, 45, 87, 99, 27 算平均
-
問int怎麼存-689這個數字。 int用4個bytes。 答案請用16進位表達。