当前位置:网站首页>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/
边栏推荐
- Binary tree creation & traversal
- Use br to back up tidb cluster data to S3 compatible storage
- Restore backup data on S3 compatible storage with tidb lightning
- Analysis of pointer and array written test questions
- [count] [combined number] value series
- File upload of DVWA range
- Wireshark grabs packets to understand its word TCP segment
- Golang DNS 随便写写
- P3047 [usaco12feb]nearby cows g (tree DP)
- Remote storage access authorization
猜你喜欢
08- [istio] istio gateway, virtual service and the relationship between them
Pyqt5 development tips - obtain Manhattan distance between coordinates
Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
NFT smart contract release, blind box, public offering technology practice -- contract
File upload of DVWA range
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
【云原生】手把手教你搭建ferry开源工单系统
将 NFT 设置为 ENS 个人资料头像的分步指南
珠海金山面试复盘
随机推荐
Restore backup data on S3 compatible storage with br
Codeforces Global Round 19(A~D)
"Designer universe" Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers | national economic and Informa
数据治理:主数据的3特征、4超越和3二八原则
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
指针和数组笔试题解析
Asia Pacific Financial Media | designer universe | Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers
Understanding of law of large numbers and central limit theorem
Hill sort c language
"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
NFT smart contract release, blind box, public offering technology practice -- contract
[redis] Introduction to NoSQL database and redis
The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
[KMP] template
数据治理:微服务架构下的数据治理
C语言 - 位段
National economic information center "APEC industry +": economic data released at the night of the Spring Festival | observation of stable strategy industry fund
It's hard to find a job when the industry is in recession
Onie supports pice hard disk
Nft智能合约发行,盲盒,公开发售技术实战--合约篇