当前位置:网站首页>LeetCode - 900. RLE iterator
LeetCode - 900. RLE iterator
2022-07-03 10:12:00 【Cute at the age of three @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;
}
}
边栏推荐
- 20220602数学:Excel表列序号
- Mise en œuvre d'OpenCV + dlib pour changer le visage de Mona Lisa
- Opencv image rotation
- About windows and layout
- Opencv interview guide
- Leetcode-513:找树的左下角值
- Leetcode-100:相同的树
- LeetCode - 460 LFU 缓存(设计 - 哈希表+双向链表 哈希表+平衡二叉树(TreeSet))*
- openEuler kernel 技术分享 - 第1期 - kdump 基本原理、使用及案例介绍
- openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
猜你喜欢

Leetcode - 460 LFU cache (Design - hash table + bidirectional linked hash table + balanced binary tree (TreeSet))*

Leetcode 300 最长上升子序列

Vgg16 migration learning source code

Leetcode-112:路径总和

The underlying principle of vector

Leetcode-106: construct a binary tree according to the sequence of middle and later traversal

What can I do to exit the current operation and confirm it twice?

Cases of OpenCV image enhancement

RESNET code details

2021-10-28
随机推荐
yocto 技术分享第四期:自定义增加软件包支持
Mise en œuvre d'OpenCV + dlib pour changer le visage de Mona Lisa
Markdown latex full quantifier and existential quantifier (for all, existential)
4G module at command communication package interface designed by charging pile
Circular queue related design and implementation reference 1
20220601数学:阶乘后的零
4G module designed by charging pile obtains signal strength and quality
LeetCode - 703 数据流中的第 K 大元素(设计 - 优先队列)
20220608其他:逆波兰表达式求值
The underlying principle of vector
After clicking the Save button, you can only click it once
El table X-axis direction (horizontal) scroll bar slides to the right by default
(1) What is a lambda expression
Modelcheckpoint auto save model
LeetCode - 900. RLE 迭代器
openCV+dlib實現給蒙娜麗莎換臉
Leetcode-100:相同的树
LeetCode 面试题 17.20. 连续中值(大顶堆+小顶堆)
Leetcode-112:路径总和
Opencv notes 17 template matching