← 返回 meta 的题目列表Determine if Ranges Overlap
类型:online_judge
Given two instances of a Range class, determine if they overlap. The Range class is defined as:
class Range {
constructor(start, end) {
this.start = start;
this.end = end;
}
}
Write a function doRangesOverlap(range1, range2) to check if two ranges intersect.
Input Description:
range1 and range2 are two different Range instances.
Output Description:
Return true if range1 and range2 overlap; otherwise, return false.
Example:
Input: [0, 5], [3, 10]
Output: true
Input: [0, 2], [3, 10]
Output: false
Constraints:
Both start and end are integers satisfying 0 <= start <= end <= 10^6.
Example
Input
0 5 3 10