国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Leetcode2432. The Employee That Worked on the Longest Task

2022-12-24 14:14 作者:您是打尖兒還是住店呢  | 我要投稿

There are?n?employees, each with a unique id from?0?to?n - 1.

You are given a 2D integer array?logs?where?logs[i] = [idi, leaveTimei]?where:

  • idi?is the id of the employee that worked on the?ith?task, and

  • leaveTimei?is the time at which the employee finished the?ith?task. All the values?leaveTimei?are?unique.

Note that the?ith?task starts the moment right after the?(i - 1)th?task ends, and the?0th?task starts at time?0.

Return?the id of the employee that worked the task with the longest time.?If there is a tie between two or more employees, return?the?smallest?id among them.

?

Example 1:

Input: n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]Output: 1Explanation: Task 0 started at 0 and ended at 3 with 3 units of times. Task 1 started at 3 and ended at 5 with 2 units of times. Task 2 started at 5 and ended at 9 with 4 units of times. Task 3 started at 9 and ended at 15 with 6 units of times. The task with the longest time is task 3 and the employee with id 1 is the one that worked on it, so we return 1.

Example 2:

Input: n = 26, logs = [[1,1],[3,7],[2,12],[7,17]]Output: 3Explanation: Task 0 started at 0 and ended at 1 with 1 unit of times. Task 1 started at 1 and ended at 7 with 6 units of times. Task 2 started at 7 and ended at 12 with 5 units of times. Task 3 started at 12 and ended at 17 with 5 units of times. The tasks with the longest time is task 1. The employees that worked on it is 3, so we return 3.

Example 3:

Input: n = 2, logs = [[0,10],[1,20]]Output: 0Explanation: Task 0 started at 0 and ended at 10 with 10 units of times. Task 1 started at 10 and ended at 20 with 10 units of times. The tasks with the longest time are tasks 0 and 1. The employees that worked on them are 0 and 1, so we return the smallest id 0.

?

Constraints:

  • 2 <= n <= 500

  • 1 <= logs.length <= 500

  • logs[i].length == 2

  • 0 <= idi <= n - 1

  • 1 <= leaveTimei <= 500

  • idi != idi+1

  • leaveTimei?are sorted in a strictly increasing order.

其實用優(yōu)先隊列就可以的,提前定義好排序的依據(jù),只是排序的依據(jù)是2個條件處理;

有點想不起來了,就直接數(shù)組loop出來了。

Runtime12 ms

Beats

9.18%

Memory41.8 MB

Beats

99.83%


Leetcode2432. The Employee That Worked on the Longest Task的評論 (共 條)

分享到微博請遵守國家法律
卢湾区| 青海省| 陵川县| 宜春市| 阿拉善盟| 栾城县| 南城县| 揭西县| 丰县| 东乡县| 邹平县| 盐城市| 临邑县| 井研县| 瑞昌市| 永丰县| 涡阳县| 余江县| 武平县| 婺源县| 巨野县| 友谊县| 肇东市| 柳林县| 荔波县| 凤台县| 义乌市| 富裕县| 鲜城| 蚌埠市| 五原县| 成都市| 无极县| 竹山县| 玉门市| 闵行区| 盐池县| 额尔古纳市| 武鸣县| 西藏| 定陶县|