当前位置:网站首页>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/
边栏推荐
- 1. Color inversion, logarithmic transformation, gamma transformation source code - miniopencv from zero
- 使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
- Machine learning - decision tree
- CAD ARX gets the current viewport settings
- A Closer Look at How Fine-tuning Changes BERT
- 数据治理:微服务架构下的数据治理
- Analysis of pointer and array written test questions
- [Yugong series] February 2022 U3D full stack class 010 prefabricated parts
- Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
- Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
猜你喜欢

Risk planning and identification of Oracle project management system

Pangolin Library: control panel, control components, shortcut key settings

ESP系列引脚說明圖匯總

Golang DNS 随便写写

Go learning notes (3) basic types and statements (2)

Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation

How to prevent Association in cross-border e-commerce multi account operations?

Step by step guide to setting NFT as an ens profile Avatar
![[research materials] 2022 China yuancosmos white paper - Download attached](/img/b4/422dff0510bbe67f3578202d6e80b7.jpg)
[research materials] 2022 China yuancosmos white paper - Download attached

2.10transfrom attribute
随机推荐
[redis] Introduction to NoSQL database and redis
Tidb backup and recovery introduction
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
Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
使用 TiDB Lightning 恢复 S3 兼容存储上的备份数据
数据治理:微服务架构下的数据治理
Risk planning and identification of Oracle project management system
Onie supports pice hard disk
让学指针变得更简单(三)
使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
hcip--mpls
指针和数组笔试题解析
CAD ARX 获取当前的视口设置
Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
wincc7.5下载安装教程(Win10系统)
MySQL view tablespace and create table statements
flask返回文件下载
Redis list detailed explanation of character types yyds dry goods inventory
你想知道的ArrayList知识都在这
[research materials] 2021 China online high growth white paper - Download attached