当前位置:网站首页>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;}
边栏推荐
猜你喜欢
【数据架构】概念数据模型和逻辑数据模型有什么区别
win下的开发环境变量记录
用高质量图像标注数据加速AI商业化落地
「微服务架构」编曲与编舞——让系统协同工作的不同模式
07 【动态组件 组件注册】
JWT: To own me is to have power
支付 x 聚合 x 分账 - 回流平台“二清”风险规避之路
MySQL 执行查询流程
"Microservice Architecture" Arrangement and Choreography - Different Models for Making Systems Work Together
Development environment variable record under win
随机推荐
在“企业通讯录”的盲区,融云的边界与分寸
反射效率为什么低?
LeetCode Algorithm 1403. 非递增顺序的最小子序列
Guo Jingjing's personal chess teaching, the good guy is a robot
CatchAdmin实战教程(四)Table组件之自定义基础页面
06 【生命周期 模板引用】
09 【Attributes继承 provide与inject】
序列化技术ProtoBuf
Relearn bubble sort
绘制温度曲线图;QChart,
"Microservice Architecture" Arrangement and Choreography - Different Models for Making Systems Work Together
「数据架构」数据模型,数据字典,数据库模式 和ERD的比较
MySQL executes the query process
08 【Props 组件事件】
态势丨黑客侵扰加剧,靶场为网络安全架设“防御盾”
【微服务架构】微服务与SOA架构(2)
[Internet of Things Architecture] The most suitable open source database for the Internet of Things
「数据战略」结果驱动的企业数据策略:组织和治理
Fourier series and Fourier transform
杭电多校七 1008-Triangle Game(博弈)