Skip to content

feat: add solutions to lc problem: No.1726 #869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 27, 2022
Merged

feat: add solutions to lc problem: No.1726 #869

merged 4 commits into from
Oct 27, 2022

Conversation

ifmagic
Copy link
Contributor

@ifmagic ifmagic commented Oct 27, 2022

No.1726.Tuple with Same Product

No.1726.Tuple with Same Product
@yanglbme
Copy link
Member

Python 有较为简洁的写法:

class Solution:
    def tupleSameProduct(self, nums: List[int]) -> int:
        cnt = defaultdict(int)
        for i in range(1, len(nums)):
            for j in range(i):
                x = nums[i] * nums[j]
                cnt[x] += 1
        return sum(v * (v - 1) // 2 for v in cnt.values()) << 3

我稍微改一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants