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

herrDeng網內搜尋

自訂搜尋

Ads

2026年8月4日 星期二

Leetcode 3731 Missing Elements:試試 bitset 與1-line Python set,0ms 擊敗 100% 使用者


0ms CPP bitset Py3 1 liner set速解Leetcode 3731  Find Missing Elements
[Py3 一行解請進]

 #anwendeng 
----
00:00 – Performance Result: 0ms (100% Beat)
00:25 – Problem Overview: Finding Missing Elements in a Range
01:05 – C++ Solution: Using bitset for Optimal Efficiency
01:51 – Python Solution: Using Set and Range Comparison
02:34 – Conclusion and Final Result
class Solution:
    def findMissingElements(self, nums: List[int]) -> List[int]:
        return (K:=set(nums)) and [x for x in range(min(K)+1, max(K)) if x not in K]

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章