Problem 795. Joining Ranges
You are given a n-by-2 matrix. Each row represents a numeric range, e.g.
x = [0 5; 10 3; 20 15; 16 19; 25 25]
contains ranges [0 5], [10 3], [20 15], [16 19], and [25 25]. Note that the first column does not always contain the smaller number. Join all overlapping ranges and return the sorted (both columns and all rows must be sorted) matrix of joined ranges
y = [0 10; 15 20; 25 25]
i.e. ranges [0 5] and [10 3] are combined to [0 10], range [16 19] is completely overlapped by [15 20] and [25 25] is kept because it is a separate range.
Solution Stats
Problem Comments
-
1 Comment
Kunjunni Mohanan
on 1 Sep 2020
nice problem
Solution Comments
Show commentsProblem Recent Solvers365
Suggested Problems
-
Renaming a field in a structure array
1548 Solvers
-
Project Euler: Problem 1, Multiples of 3 and 5
3356 Solvers
-
Cell Counting: How Many Draws?
2114 Solvers
-
401 Solvers
-
5196 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!