Solved Peaks in java