本片展示如何理解這題排列組合實質內容,以及如何完成 1 行Python程式碼。
[Py3 code請進]
-----------------------
This film shows how to undertand the combinatorial content for this question, and how write it in 1-line Python code.
class Solution: def tupleSameProduct(self, nums: List[int]) -> int: return sum(f*(f-1)*4 for f in (Counter(x*y for x, y in combinations(nums, 2))).values())
沒有留言:
張貼留言