当前位置:网站首页>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/
边栏推荐
- Migrate data from a tidb cluster to another tidb cluster
- matplotlib. Widgets are easy to use
- Helm install Minio
- 23. Update data
- Go learning notes (3) basic types and statements (2)
- [research materials] 2021 live broadcast annual data report of e-commerce - Download attached
- ESP系列引脚說明圖匯總
- Sanzi chess (C language)
- Redis list detailed explanation of character types yyds dry goods inventory
- C language - bit segment
猜你喜欢
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
21. Delete data
Database basic commands
[redis] Introduction to NoSQL database and redis
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
Document 2 Feb 12 16:54
07- [istio] istio destinationrule (purpose rule)
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
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
National economic information center "APEC industry +": economic data released at the night of the Spring Festival | observation of stable strategy industry fund
随机推荐
Migrate data from CSV files to tidb
Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
CAD ARX 获取当前的视口设置
Golang DNS write casually
Data governance: Data Governance under microservice architecture
Image fusion -- challenges, opportunities and Countermeasures
[count] [combined number] value series
Upgrade tidb with tiup
Webrtc series-h.264 estimated bit rate calculation
Asia Pacific Financial Media | female pattern ladyvision: forced the hotel to upgrade security. The drunk woman died in the guest room, and the hotel was sentenced not to pay compensation | APEC secur
让学指针变得更简单(三)
Risk planning and identification of Oracle project management system
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
07- [istio] istio destinationrule (purpose rule)
Entity class design for calculating age based on birthday
Remote storage access authorization
Erc20 token agreement
A Closer Look at How Fine-tuning Changes BERT
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
flask返回文件下载