当前位置:网站首页>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/
边栏推荐
- "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
- Vit (vision transformer) principle and code elaboration
- Redis list detailed explanation of character types yyds dry goods inventory
- Image fusion -- challenges, opportunities and Countermeasures
- Secure captcha (unsafe verification code) of DVWA range
- NFT smart contract release, blind box, public offering technology practice -- jigsaw puzzle
- 将 NFT 设置为 ENS 个人资料头像的分步指南
- 使用 TiDB Lightning 恢复 S3 兼容存储上的备份数据
- Golang DNS 随便写写
- Use br to back up tidb cluster data to S3 compatible storage
猜你喜欢

Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
![[research materials] 2022 China yuancosmos white paper - Download attached](/img/b4/422dff0510bbe67f3578202d6e80b7.jpg)
[research materials] 2022 China yuancosmos white paper - Download attached
![08- [istio] istio gateway, virtual service and the relationship between them](/img/fb/09793f5fd12c2906b73cc42722165f.jpg)
08- [istio] istio gateway, virtual service and the relationship between them

C语言自定义类型:结构体

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

Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

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

How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship

24. Query table data (basic)
随机推荐
CAD ARX gets the current viewport settings
【T31ZL智能视频应用处理器资料】
[count] [combined number] value series
C language custom type: struct
JS select all and tab bar switching, simple comments
P3047 [usaco12feb]nearby cows g (tree DP)
Inspiration from the recruitment of bioinformatics analysts in the Department of laboratory medicine, Zhujiang Hospital, Southern Medical University
Restore backup data on S3 compatible storage with tidb lightning
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
Pyqt5 development tips - obtain Manhattan distance between coordinates
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
Remote storage access authorization
Parameter self-tuning of relay feedback PID controller
TiDB备份与恢复简介
Résumé des diagrammes de description des broches de la série ESP
23. Update data
What are the ways to download network pictures with PHP
数据治理:误区梳理篇
[research materials] 2021 live broadcast annual data report of e-commerce - Download attached
数据治理:微服务架构下的数据治理