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

herrDeng網內搜尋

自訂搜尋

Ads

2025年9月10日 星期三

C++示範bitset取代hashset解Leetcode 1733 Minimum Number of People to Teach(含Py3 code)


C++示範bitset取代hashset解Leetcode 1733  Minimum Number of People to Teach
C++ STL的unordered_set與bitset都能解這題,但執行效率差很多,有誰寫C++其執行效能要比類似的Python code還要慢上好久倍?用hashset就如此
[Python code請進 ]

2025年9月6日 星期六

C++C py3 log4 prefix sum, bits解Leetcode難題3495 Minimum Operations to Mak...


C++C py3 log4 prefix sum/bits解Leetcode難題3495  Minimum Operations to Make Array Elements Zero
ceil(log4(x)) 可以透過 clz 計算;將 expSum 定義為部分和來計算。
[Py3 code請進]

2025年8月31日 星期日

C++回遡與bitmask解Leetcode 37數獨Sudoku


C++回遡與bitmask解Leetcode 37數獨Sudoku
有些經典問題值得一解再解,雖然不是最佳解,也要比Leetcode Editorial的解有效許多。解數獨,回遡乃基本款,但加上bitmask就能篩掉許多無用的測試,就更快許多
-----
Some classic problems are worth solving again and again. Although they are not the best solutions, they are much more effective than Leetcode Editorial's solutions. Solve Sudoku by using backtracking is the basic version, but add bitmask to filter out many useless tests can make it much faster.
[其他採回溯未用bitmask解法]https://www.youtube.com/watch?v=wviWrbbOdYE

2025年8月28日 星期四

Py3 C++速解Leetcode 3446 Sort Matrix by Diagonals/with Py3 code


Py3 C++速解Leetcode 3446  Sort Matrix by Diagonals
矩陣問題都是很好的迴圈、陣列練習,又加上排序那就是很好的練習題
[Py3 code請進]

2025年8月27日 星期三

C++ dp動態規劃解Leetcode 3459 Length of Longest V Shaped Diagonal Segment


C++ dp動態規劃解Leetcode 3459  Length of Longest V Shaped Diagonal Segment
採DP動態規劃迭代版本解難題,需要定義V-shaped distance
------
Using the DP dynamic programming iterative version, it is necessary to define the V-shaped distance
Related Posts Plugin for WordPress, Blogger...

熱門文章