当前位置:网站首页>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;
}
}
边栏推荐
- 2.1 Dynamic programming and case study: Jack‘s car rental
- LeetCode - 706 设计哈希映射(设计) *
- Modelcheckpoint auto save model
- Swing transformer details-2
- getopt_ Typical use of long function
- LeetCode - 705 设计哈希集合(设计)
- Deep learning by Pytorch
- LeetCode - 1670 設計前中後隊列(設計 - 兩個雙端隊列)
- After clicking the Save button, you can only click it once
- LeetCode - 1172 餐盘栈 (设计 - List + 小顶堆 + 栈))
猜你喜欢

2021-10-28

Opencv notes 20 PCA

2.2 DP: Value Iteration & Gambler‘s Problem

CV learning notes - Stereo Vision (point cloud model, spin image, 3D reconstruction)

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

The underlying principle of vector

『快速入门electron』之实现窗口拖拽

Leetcode bit operation

Matplotlib drawing

openEuler kernel 技术分享 - 第1期 - kdump 基本原理、使用及案例介绍
随机推荐
Leetcode-112: path sum
1. Finite Markov Decision Process
LeetCode - 5 最长回文子串
Vgg16 migration learning source code
CV learning notes - camera model (Euclidean transformation and affine transformation)
20220610其他:任务调度器
LeetCode - 703 数据流中的第 K 大元素(设计 - 优先队列)
Open Euler Kernel Technology Sharing - Issue 1 - kdump Basic Principles, use and Case Introduction
One click generate traffic password (exaggerated advertisement title)
Deep learning by Pytorch
CV learning notes - reasoning and training
CV learning notes - feature extraction
Opencv notes 20 PCA
QT detection card reader analog keyboard input
. DLL and Differences between lib files
4G module designed by charging pile obtains signal strength and quality
2. Elment UI date selector formatting problem
Installation and removal of MySQL under Windows
20220601数学:阶乘后的零
03 fastjason solves circular references