Skip to content

Commit d2add3e

Browse files
authored
Create 1503-last-moment-before-all-ants-fall-out-of-a-plank.js
1 parent 992c6c7 commit d2add3e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number} n
3+
* @param {number[]} left
4+
* @param {number[]} right
5+
* @return {number}
6+
*/
7+
var getLastMoment = function(n, left, right) {
8+
left.sort(function(a,b){return a-b});
9+
right.sort(function(a,b){return a-b});
10+
if(left.length == 0){
11+
return n-right[0];
12+
}
13+
if(right.length == 0){
14+
return left[left.length-1];
15+
}
16+
return Math.max(left[left.length-1], n-right[0])
17+
};

0 commit comments

Comments
 (0)