# Best Data Structure to solve this problem

danial leksevo

Greenhorn

Posts: 3

posted 5 years ago

Hi All,

Could you please suggest me which data structure is best to use to solve this problem

I have set of int ranges in the form of two dimensional array e.g

I want to combining ranges wherever possible to make a range which cover all of sub-set of the ranges e.g

and my final set of ranges will be like

for this problem, please suggest me which data structure is the best to use. And any idea how I should combine the ranges.

Thanks in advance!

Best

Danial

Could you please suggest me which data structure is best to use to solve this problem

I have set of int ranges in the form of two dimensional array e.g

**int[][] array= {{1- 4},{6-10}{8-20},{20- 30},{50-60}};**I want to combining ranges wherever possible to make a range which cover all of sub-set of the ranges e.g

**{{6-10}{8-20},{20- 30}}={6-30}**and my final set of ranges will be like

**array= {{1- 4},{6-30},{50-60}}**for this problem, please suggest me which data structure is the best to use. And any idea how I should combine the ranges.

Thanks in advance!

Best

Danial