当前位置:网站首页>2022.8.7-----leetcode.636
2022.8.7-----leetcode.636
2022-08-10 10:04:00 【Road Lu727】
public int[] exclusiveTime(int n, List logs) {int[] ans=new int[n];Deque s=new ArrayDeque<>();//Simulate the current callDeque s1=new ArrayDeque<>();//Store the start and end points of the ended function, including functions at the same level and internal functionsfor(String log:logs){String[] ss=log.split(":");if(ss[1].equals("start")){//The call start point is pushed into the stacks.add(new int[]{Integer.parseInt(ss[0]),Integer.parseInt(ss[2])});}else{int[] tmp=s.pollLast();int time=Integer.parseInt(ss[2])-tmp[1]+1;//The calling interval of the current end functionwhile(!s1.isEmpty()&&s1.getLast()[0]>=tmp[1]){int[] tmp1=s1.pollLast();time-=tmp1[1]-tmp1[0]+1;//Determine whether the ended function is inside the current end function}ans[tmp[0]]+=time;//accumulate times1.add(new int[]{tmp[1],Integer.parseInt(ss[2])});//Add the current end function to the stack}}return ans;} 边栏推荐
- LCD DRM component 框架分析
- Excel绘制统计图
- CatchAdmin实战教程(四)Table组件之自定义基础页面
- 90.(cesium之家)cesium高度监听事件
- [Concept of Theory of Knowledge] "Progress in the Theory of Reason" University of Leuven 2022 latest 220-page doctoral dissertation
- LeetCode Algorithm 1403. 非递增顺序的最小子序列
- 【分布式】资源与事务:可观测性的基本二重性
- 多元线性回归分析(Stata)
- 【物联网架构】最适合物联网的开源数据库
- C语言题解:倒置字符串
猜你喜欢
随机推荐
大连理工&鹏城&UAE提出用于伪装目标检测的混合尺度三重网络ZoomNet,性能SOTA!
JWT: To own me is to have power
武功修炼:招式
Plot temperature curves; QChart,
关于编程本质那些事
第三章 搜索与图论(三)
Lasso回归(Stata)
win下的开发环境变量记录
Chapter 3 Search and Graph Theory (3)
「数据战略」结果驱动的企业数据策略:组织和治理
ESP8266-Arduino编程实例-MQ-8氢气传感器驱动
高通 msm8953 LCD 休眠/唤醒 流程
「第二部:容器和微服务架构」(1) 基于容器应用架构设计原则
ELK入门
俄罗斯宣布临时禁止进口摩尔多瓦植物产品
LiveGBS操作日志页面快速的筛选上级平台的调用记录直播观看录像回看等操作
中国驻越南使馆提醒在越北部、中部地区中国公民做好台风“木兰”安全防范
PostgreSQL 2022 发展现状:13 个非 psql 工具
"Microservice Architecture" Arrangement and Choreography - Different Models for Making Systems Work Together
「业务架构」TOGAF建模:业务功能分解图









