Problem Statement
One of Snow White's seven dwarves has gone missing! She is sure he will turn up eventually, but she needs to know his height because she is knitting him a sweater. Here is what she remembers about the heights:
- The missing dwarf is strictly taller than any of the other six dwarves.
- The height of each dwarf is a positive integer.
- The average of all seven heights is also a positive integer.
You are given the
Definition
- Class:
- MissingDwarf
- Method:
- getHeight
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int getHeight(int[] otherHeights)
- (be sure your method is public)
Constraints
- otherHeights will contain exactly 6 elements.
- Each element of otherHeights will be between 1 and 1000, inclusive.
Examples
{1,2,3,4,5,6}
Returns: 7
The height of the missing dwarf is 7. (The average height of a dwarf is exactly 4.)
{6,5,4,3,2,1}
Returns: 7
The six heights can be given in any order.
{10,10,20,20,30,30}
Returns: 34
Sometimes some of the six heights given as the input can be equal.
{7,7,7,7,7,7}
Returns: 14
The missing dwarf must be taller than each of the six remaining dwarves.
{1000,1000,1000,1000,1000,1000}
Returns: 1007
{1000,1000,997,1000,1000,1000}
Returns: 1003
{353,545,432,325,42,425}
Returns: 552
{353,545,432,325,43,425}
Returns: 551
{353,545,432,325,44,425}
Returns: 550
{353,545,432,325,45,425}
Returns: 549
{353,545,432,325,46,425}
Returns: 548
{353,545,432,325,47,425}
Returns: 547
{353,545,432,325,48,425}
Returns: 546
{7, 7, 7, 7, 7, 7 }
Returns: 14
{1000, 1000, 1000, 1000, 1000, 1000 }
Returns: 1007
{10, 10, 20, 20, 30, 30 }
Returns: 34
{6, 6, 6, 6, 6, 6 }
Returns: 13