A group of n thieves needs some software to help them divide up their loot.
A necklace must be divided up as evenly as possible among the gang members.
The necklace is a circle of gems of different values.
The requirement is
that the necklace be divided into n segments by cutting the necklace in n places.
Every segment must contain at least one gem. The "inequity" of the division is
the value of the mostvaluable segment minus the value of the leastvaluable
segment. (The value of a segment is the sum of the values of the gems in that
segment.) We want to minimize the inequity.
Create a class Necklaces that contains a method inequity that is given as input n
and a int[] gems (the values of each gem in the
necklace in order). The gems are in a circle, so the last element of gems is
connected to the first element. The method should find the best way to divide
the necklace and return the minimum
possible inequity.
