0ms CPP bitset Py3 1 liner set速解Leetcode 3731 Find Missing Elements
[Py3 一行解請進]
[codes on Leetcode]https://leetcode.com/problems/find-missing-elements/solutions/8439523/bitset-is-good0ms-by-anwendeng-bxpu/
#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]
沒有留言:
張貼留言
HTML 編輯器