当前位置:网站首页>Leetcode: the shortest dice sequence impossible to get [thinking questions + grouping ideas]
Leetcode: the shortest dice sequence impossible to get [thinking questions + grouping ideas]
2022-07-24 21:54:00 【White speed Dragon King's review】

analysis
A group of 1-k Can create a length
use set See how many groups you can save 1-k
Then the answer is how many groups + 1
ac code
class Solution:
def shortestSequence(self, rolls: List[int], k: int) -> int:
# Thinking questions , A group of 1-k Make a length
s = set()
ans = 0
for num in rolls:
s.add(num)
if len(s) == k:
s.clear()
ans += 1
return ans + 1
summary
Thinking first
The idea of grouping and blocking
边栏推荐
- Is it safe to open an account on Alipay
- [CCNA experiment sharing] routing between VLANs of layer 3 switches
- MySQL forced indexing
- Drawing library Matplotlib styles and styles
- Codeforces Round #808 (Div. 2)(A~D)
- Atcoder beginer contest 260 a~f problem solution
- 微机原理:CPU架构详解
- 2022 Niuke multi school 7.23
- How does novice Xiaobai build a personal server?
- None of the most complete MySQL commands in history is applicable to work and interview (supreme Collection Edition)
猜你喜欢

Gather relevant knowledge points and expand supplements

Information system project manager must recite the core examination site (47) project subcontract

MQ release confirmation

小程序地理位置接口申请

Together again Net program hangs dead, a real case analysis of using WinDbg

【MLFP】《Face Presentation Attack with Latex Masks in Multispectral Videos》

How do test / development programmers survive the midlife crisis? You can see it at a glance

Uniqueness and ordering in set

Lenovo Filez helps Zhongshui North achieve safe and efficient file management

Redis (12) -- redis server
随机推荐
OSI的体系结构,以及各层协议
With this PDF, I successfully got offers from ant, jd.com, Xiaomi, Tencent and other major manufacturers
Binary search
巧妙使用sort(List<T>,Comparator<? super T>)比较器
How to realize three schemes of finclip wechat authorized login
Multiplication and addition of univariate polynomials
What should I pay attention to when choosing the self built database access method on ECs?
微信小程序监听实时地理位置变化事件接口申请
Mysql database commands
Scientific computing toolkit SciPy data interpolation
Documentary of the second senior brother
OSI architecture and protocols at all levels
《论文复现》BiDAF代码实现过程(4)模型训练+验证
A very useful log4net logging library
Scientific computing toolkit SciPy image processing
Establishment of China Mobile Chain (EOS based) test environment
P2404 splitting of natural numbers
LED digital display driver IC and anti-interference LED digital tube display driver ic-vk1s68c ssop24 are applicable to finger clip pulse oximeter, arm electronic sphygmomanometer, thermometer, fetal
Unfair distribution
How to drain the applet correctly? Three positions of whole network drainage!