当前位置:网站首页>2022-02-14 (394. String decoding)
2022-02-14 (394. String decoding)
2022-07-03 04:17:00 【TickTick123】
class Solution {
public String decodeString(String s) {
StringBuilder res = new StringBuilder();
int multi = 0;
Stack<Integer> stack_multi = new Stack<>();
Stack<String> stack_res = new Stack<>();
for(Character c : s.toCharArray()) {
if(c == '[') {
stack_multi.push(multi);
stack_res.push(res.toString());
multi = 0;
res = new StringBuilder();
}
else if(c == ']') {
StringBuilder tmp = new StringBuilder();
int cur_multi = stack_multi.pop();
for(int i = 0; i < cur_multi; i++) tmp.append(res);
res = new StringBuilder(stack_res.pop() + tmp);
}
else if(c >= '0' && c <= '9') multi = multi * 10 + Integer.parseInt(c + "");
else res.append(c);
}
return res.toString();
}
}
边栏推荐
- Introduction of pointer variables in function parameters
- Arduino application development - LCD display GIF dynamic diagram
- Is it better to speculate in the short term or the medium and long term? Comparative analysis of differences
- Which Bluetooth headset is cost-effective? Four Bluetooth headsets with high cost performance are recommended
- sd卡数据损坏怎么回事,sd卡数据损坏怎么恢复
- 【刷题篇】多数元素(超级水王问题)
- [set theory] set concept and relationship (true subset | empty set | complete set | power set | number of set elements | power set steps)
- 商城系统搭建完成后需要设置哪些功能
- Nat. Comm. | use tensor cell2cell to deconvolute cell communication with environmental awareness
- redis 持久化原理
猜你喜欢

中移物联网OneOS与OneNET入选《2021年物联网示范项目名单》

Database management tool, querious direct download
![[home push IMessage] software installation virtual host rental tothebuddy delay](/img/e7/eb20a773e4b674962f856d179a3769.jpg)
[home push IMessage] software installation virtual host rental tothebuddy delay

Redis persistence principle

会员积分商城系统的功能介绍

Pdf editing tool movavi pdfchef 2022 direct download

2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func main() { var a =

GFS分布式文件系统(光是遇见已经很美好了)

Nodejs Foundation: shallow chat URL and querystring module

使用BENCHMARKSQL工具对kingbaseES执行灌数据提示无法找到JDBC driver
随机推荐
Fcpx template: sweet memory electronic photo album photo display animation beautiful memory
300+ documents! This article explains the latest progress of multimodal learning based on transformer
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
RSRS指标择时及大小盘轮动
Nodejs Foundation: shallow chat URL and querystring module
vulnhub HA: Natraj
国产PC系统完成闭环,替代美国软硬件体系的时刻已经到来
2022 beautician (intermediate) new version test questions and beautician (intermediate) certificate examination
使用BENCHMARKSQL工具对kingbaseES执行灌数据提示无法找到JDBC driver
金仓数据库KingbaseES 插件kdb_date_function
[fxcg] market analysis today
The 10th China Cloud Computing Conference · China Station: looking forward to the trend of science and technology in the next decade
Arduino application development - LCD display GIF dynamic diagram
[graduation season · aggressive technology Er] Confessions of workers
Mila、渥太华大学 | 用SE(3)不变去噪距离匹配进行分子几何预训练
[set theory] set operation (Union | intersection | disjoint | relative complement | symmetric difference | absolute complement | generalized union | generalized intersection | set operation priority)
sd卡数据损坏怎么回事,sd卡数据损坏怎么恢复
Database management tool, querious direct download
Feature_selection
Mutex and rwmutex in golang