当前位置:网站首页>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;} 边栏推荐
- ESP8266 Tutorial 1 - Introduction to ESP8266 Hardware Platform
- 「数据战略」结果驱动的企业数据策略:组织和治理
- Development environment variable record under win
- dos环境下操作mysql
- LeetCode Algorithm 914. 卡牌分组
- 04 【计算属性 侦听器】
- 腾讯云校园大使开始招募啦,内推名额和奖金等你来拿
- 13 【script setup 总结】
- Guo Jingjing's personal chess teaching, the good guy is a robot
- Flutter实战-请求封装(五)之Isolate线程改造
猜你喜欢
随机推荐
The web project accesses static resources inside the reference jar
CSDN 21 Days Learning Challenge - Polymorphism (05)
GO文件相关操作使用
【物联网架构】什么是物联网平台?
10 【异步组件 组合式函数(hooks)】
「可扩展性」可扩展性最佳实践:来自eBay的经验教训
在兄弟连战狼班参加PHP培训做行业领先人才
Plot temperature curves; QChart,
数据中台解决方案及未来发展方向
负载均衡原理分析与源码解读
win下的开发环境变量记录
Payment x Aggregation x Ledger Separation - The Way to Avoid Risk of "Erqing" on the Return Platform
如何理解BIO、NIO、AIO的区别
【Software Exam System Architect】Case Analysis ⑥ Web Application System Architecture Design
The Generation of Matlab Symbolic Functions and the Calculation of Its Function Values
消息队列概述
Property animation QPropertyAnimation
Static关键字及应用,继承的概念
ES关于文档的基本操作
go web之cookie









