当前位置:网站首页>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/
边栏推荐
- [nonlinear control theory]9_ A series of lectures on nonlinear control theory
- Nacos Development Manual
- Grayscale upgrade tidb operator
- Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
- . Net 6 learning notes: what is NET Core
- [Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
- 将 NFT 设置为 ENS 个人资料头像的分步指南
- Transformer principle and code elaboration
- [research materials] 2021 Research Report on China's smart medical industry - Download attached
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
猜你喜欢

It's hard to find a job when the industry is in recession
![[count] [combined number] value series](/img/f5/6fadb8f1c8b75ddf5994c2c43feaa6.jpg)
[count] [combined number] value series

ROS learning (IX): referencing custom message types in header files

The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable

Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
![[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map](/img/c3/1b6013bfb2441219bf621c3f0726ea.jpg)
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map

Secure captcha (unsafe verification code) of DVWA range

matplotlib. Widgets are easy to use

22. Empty the table

将 NFT 设置为 ENS 个人资料头像的分步指南
随机推荐
Redis list detailed explanation of character types yyds dry goods inventory
shu mei pai
Entity class design for calculating age based on birthday
数据治理:数据质量篇
A Closer Look at How Fine-tuning Changes BERT
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
Oracle time display adjustment
Risk planning and identification of Oracle project management system
onie支持pice硬盘
07- [istio] istio destinationrule (purpose rule)
Data governance: Data Governance under microservice architecture
Machine learning - decision tree
[KMP] template
49. Sound card driven article collection
TiDB备份与恢复简介
JS select all and tab bar switching, simple comments
Parameter self-tuning of relay feedback PID controller
在 uniapp 中使用阿里图标
Transformer principle and code elaboration
Pangolin Library: control panel, control components, shortcut key settings