# 题目地址：

https://www.lintcode.com/problem/process-sequence/description

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution {

class Pair {
int time, flag;

public Pair(int time, int flag) {
this.time = time;
this.flag = flag;
}
}

/**
* @param logs: Sequence of processes
* @param queries: Sequence of queries
* @return: Return the number of processes
*/
public List<Integer> numberOfProcesses(List<Interval> logs, List<Integer> queries) {
List<Integer> res = new ArrayList<>();
List<Pair> list = new ArrayList<>();

// 将所有时间点连同它的含义做成一个pair加入list
for (Interval log : logs) {
}
for (int query : queries) {
}

list.sort((p1, p2) -> {
if (p1.time != p2.time) {
return Integer.compare(p1.time, p2.time);
}

return Integer.compare(p1.flag, p2.flag);
});

int count = 0;
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < list.size(); i++) {
Pair cur = list.get(i);
if (cur.flag == 0) {
count++;
} else if (cur.flag == 1) {
count--;
}

if (cur.flag == 2) {
map.put(cur.time, count);
}
}

for (int query : queries) {
}

return res;
}
}

class Interval {
int start, end;

public Interval(int start, int end) {
this.start = start;
this.end = end;
}
}


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

记录算法

算法不易，且行且珍惜

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文
07-19 18
08-02 1039

09-17 416
08-17 511
09-11
09-29