当前位置:网站首页>LeetCode - 900. RLE 迭代器
LeetCode - 900. RLE 迭代器
2022-07-03 09:20:00 【三岁就很萌@D】



class RLEIterator {
private int[] encoding;
private int tail;
public RLEIterator(int[] encoding) {
this.encoding = encoding;
this.tail = 0;
}
public int next(int n) {
int num = n;
int len = encoding.length;
while(tail < len && num > encoding[tail]){
num -= encoding[tail];
tail += 2;
}
if(tail < len){
encoding[tail] -= num;
return encoding[tail+1];
}
else
return -1;
}
}
边栏推荐
- My 4G smart charging pile gateway design and development related articles
- Pymssql controls SQL for Chinese queries
- (2)接口中新增的方法
- 应用最广泛的8位单片机当然也是初学者们最容易上手学习的单片机
- Swing transformer details-2
- Toolbutton property settings
- 03 FastJson 解决循环引用
- MySQL root user needs sudo login
- 4G module initialization of charge point design
- SCM career development: those who can continue to do it have become great people. If they can't endure it, they will resign or change their careers
猜你喜欢

Exception handling of arm

要选择那种语言为单片机编写程序呢

Leetcode 300 最长上升子序列

openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹

Adaptiveavgpool1d internal implementation

03 FastJson 解决循环引用

Programming ideas are more important than anything, not more than who can use several functions, but more than the understanding of the program
![[Li Kou brush question notes (II)] special skills, module breakthroughs, classification and summary of 45 classic questions, and refinement in continuous consolidation](/img/06/7fd985faf8806ceface3864d4b3180.png)
[Li Kou brush question notes (II)] special skills, module breakthroughs, classification and summary of 45 classic questions, and refinement in continuous consolidation

yocto 技術分享第四期:自定義增加軟件包支持

单片机现在可谓是铺天盖地,种类繁多,让开发者们应接不暇
随机推荐
Exception handling of arm
A lottery like scissors, stone and cloth (C language)
03 fastjason solves circular references
自动装箱与拆箱了解吗?原理是什么?
Sending and interrupt receiving of STM32 serial port
我想各位朋友都应该知道学习的基本规律就是:从易到难
2021-10-27
Gif image analysis drawing RGB to YUV table lookup method to reduce CPU occupancy
Simulate mouse click
QT is a method of batch modifying the style of a certain type of control after naming the control
03 FastJson 解决循环引用
STM32 general timer output PWM control steering gear
对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
Circular queue related design and implementation reference 1
Installation and removal of MySQL under Windows
The data read by pandas is saved to the MySQL database
On the problem of reference assignment to reference
Crash工具基本使用及实战分享
(1) What is a lambda expression
Serial communication based on 51 single chip microcomputer