Skip to content

Commit

Permalink
Update insert-interval/wogha95.js
Browse files Browse the repository at this point in the history
Co-authored-by: Dale Seo <[email protected]>
  • Loading branch information
wogha95 and DaleSeo authored Oct 24, 2024
1 parent 11bd72a commit 46a14fe
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions insert-interval/wogha95.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ var insert = function (intervals, newInterval) {
let overLappingEndIndex = 0;
for (let index = 0; index < intervals.length; index++) {
const interval = intervals[index];
if (
(interval[0] <= newInterval[0] && newInterval[0] <= interval[1]) ||
newInterval[0] < interval[0]
) {
if (newInterval[0] <= interval[1]) {
overLappingStartIndex = Math.min(overLappingStartIndex, index);
}
if (
(interval[0] <= newInterval[1] && newInterval[1] <= interval[1]) ||
interval[1] < newInterval[1]
) {
if (interval[0] <= newInterval[1]) {
overLappingEndIndex = Math.max(overLappingEndIndex, index);
}
}
Expand Down

0 comments on commit 46a14fe

Please sign in to comment.