当前位置:网站首页>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;}
边栏推荐
- 腾讯发布四足机器人 Max 二代版本,梅花桩上完成跳跃、空翻
- 【Prometheus】Node Exporter常用查询PromQL 语句大总结
- ESP8266 教程1 — ESP8266硬件平台介绍
- 【软考 系统架构设计师】案例分析⑥ Web应用系统架构设计
- vs2012创建WCF应用程序
- 【知识论概念】《理由论的进展》鲁汶大学2022最新220页博士论文
- Excel draws statistical graphs
- [Internet of Things Architecture] The most suitable open source database for the Internet of Things
- Controller层代码这么写,简洁又优雅!
- 「应用架构」TOGAF建模:企业可管理性图
猜你喜欢
随机推荐
LCD DRM component 框架分析
WebView2 通过 PuppeteerSharp 实现爬取 王者 壁纸 (案例版)
90.(cesium之家)cesium高度监听事件
Tencent releases the second-generation version of the quadruped robot Max, which completes jumps and somersaults on the plum blossom pile
重学冒泡排序
中国驻越南使馆提醒在越北部、中部地区中国公民做好台风“木兰”安全防范
交换 生成树 知识总结
"Data Architecture": How can master data management (MDM) help my industry?
武功修炼:招式
属性动画QPropertyAnimation
ESP8266-Arduino编程实例-MQ-8氢气传感器驱动
绘制温度曲线图;QChart,
VBA:获取指定数值在指定一维数组中的位置
ES关于文档的基本操作
LiveNVR操作日志页面快速筛选上级国标平台的调用记录直播观看录像回看等操作
效率开发目录
Which is the strongest workflow engine for "Technology Selection"?Chief Architecture Helps You Pick
如何理解BIO、NIO、AIO的区别
Payment x Aggregation x Ledger Separation - The Way to Avoid Risk of "Erqing" on the Return Platform
Controller层代码这么写,简洁又优雅!