GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

retrun the list of ranges

 

Implement method:

Lìst<Range> getRanges(Lìst<Shard> shards, Lìst<Key> keys)

That returns list of ranges. Each range represents multiple keys aggregated over a shard:

n-keys —> 1-shard —> l-range

 

Method should return no more than 1 range per shard that spans all keys or their parts belonging to this shard.

 

Each of the ‘Range` , 'Shard’ and ‘Key’ classes have ‘end’ and ‘start’ fields of int type, where ‘start’ is inclusive and ‘end’ is exclusive.

 

Example:

 

1—9, 12—59, 100—999 <— shards (input)

2—3, 6—8, 11—20, 200—220 <— keys (input)

2—8, 12—20, 200—220 <— ranges (output)

 

 

asked Sep 21, 2016 by ermilanardeshana
...