当前位置:网站首页>Day29-t77 & t1726-2022-02-13-don't answer by yourself
Day29-t77 & t1726-2022-02-13-don't answer by yourself
2022-07-06 08:11:00 【Parchment】
77
Given two integers n and k, Return range [1, n] All the possibilities in k Combination of numbers .You can press In any order Return to the answer .
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
ans = list()
t = list()
def find_all(i,j):
if j == k:
ans.append(t[:])
else:
if i <= n- k + j + 1:
for a in range(i,n+1):
t.append(a)
find_all(a+1,j+1)
t.pop()
find_all(1,0)
return ans
# author :haotianmingyue
# link :https://leetcode-cn.com/problems/combinations/solution/python-hui-su-by-haotianmingyue-0jav/
1726 Coproduct tuple
Here you are Different An array of positive integers nums , Please return to contentment a * b = c * d tuples (a, b, c, d) The number of . among a、b、c and d All are nums The elements in , And a != b != c != d .source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/tuple-with-same-product
class Solution:
def tupleSameProduct(self, nums: List[int]) -> int:
n=len(nums)
freq = Counter([nums[i]*nums[j] for i in range(n) for j in range(i+1,n)])
cnt=0
for prod in freq:
if freq[prod]>0:
cnt+=freq[prod]*(freq[prod]-1)//2*8
return cnt
# author :yuer-flyfly
# link :https://leetcode-cn.com/problems/tuple-with-same-product/solution/ha-xi-biao-pai-lie-zu-he-tong-ji-yuan-zu-5q0v/
边栏推荐
- CAD ARX gets the current viewport settings
- [research materials] 2021 China online high growth white paper - Download attached
- Secure captcha (unsafe verification code) of DVWA range
- Epoll and IO multiplexing of redis
- Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
- 将 NFT 设置为 ENS 个人资料头像的分步指南
- C language - bit segment
- Webrtc series-h.264 estimated bit rate calculation
- Database basic commands
- [research materials] 2021 live broadcast annual data report of e-commerce - Download attached
猜你喜欢
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
From monomer structure to microservice architecture, introduction to microservices
[research materials] 2021 China online high growth white paper - Download attached
Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
Epoll and IO multiplexing of redis
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
在 uniapp 中使用阿里图标
将 NFT 设置为 ENS 个人资料头像的分步指南
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
随机推荐
22. Empty the table
Entity class design for calculating age based on birthday
[research materials] 2021 China online high growth white paper - Download attached
2.10transfrom attribute
Document 2 Feb 12 16:54
Analysis of pointer and array written test questions
数据治理:微服务架构下的数据治理
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Golang DNS write casually
【云原生】手把手教你搭建ferry开源工单系统
[research materials] 2022 China yuancosmos white paper - Download attached
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
数据治理:元数据管理篇
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
wincc7.5下载安装教程(Win10系统)
Yu Xia looks at win system kernel -- message mechanism
Codeforces Global Round 19(A~D)
[untitled]
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Grayscale upgrade tidb operator