当前位置:网站首页>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;
}
}
边栏推荐
- LeetCode - 933 最近的请求次数
- is_ power_ of_ 2 judge whether it is a multiple of 2
- A lottery like scissors, stone and cloth (C language)
- 嵌入式系统没有特别明确的定义
- Pymssql controls SQL for Chinese queries
- LeetCode - 673. 最长递增子序列的个数
- [combinatorics] combinatorial existence theorem (three combinatorial existence theorems | finite poset decomposition theorem | Ramsey theorem | existence theorem of different representative systems |
- Basic knowledge of MySQL database (an introduction to systematization)
- On the problem of reference assignment to reference
- Vgg16 migration learning source code
猜你喜欢
I think all friends should know that the basic law of learning is: from easy to difficult
Open Euler Kernel Technology Sharing - Issue 1 - kdump Basic Principles, use and Case Introduction
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
我想各位朋友都应该知道学习的基本规律就是:从易到难
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
Blue Bridge Cup for migrant workers majoring in electronic information engineering
YOLO_ V1 summary
Stm32f407 key interrupt
51 MCU tmod and timer configuration
[combinatorics] Introduction to Combinatorics (combinatorial idea 3: upper and lower bound approximation | upper and lower bound approximation example Remsey number)
随机推荐
Vscode markdown export PDF error
QT is a method of batch modifying the style of a certain type of control after naming the control
Education is a pass and ticket. With it, you can step into a higher-level environment
Gif image analysis drawing RGB to YUV table lookup method to reduce CPU occupancy
Pymssql controls SQL for Chinese queries
I think all friends should know that the basic law of learning is: from easy to difficult
4G module IMEI of charging pile design
Simple use of MySQL (addition, deletion, modification and query)
对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
Development of intelligent charging pile (I): overview of the overall design of the system
[untitled] proteus simulation of traffic lights based on 89C51 Single Chip Microcomputer
[keil5 debugging] warning:enumerated type mixed with other type
Google browser plug-in recommendation
Opencv notes 17 template matching
Do you understand automatic packing and unpacking? What is the principle?
使用sed替换文件夹下文件
I didn't think so much when I was in the field of single chip microcomputer. I just wanted to earn money to support myself first
01 business structure of imitation station B project
ADS simulation design of class AB RF power amplifier