# Codility Calcium 2015

## Introduction

This is an solution in java of Codility Calcium 2015.

You can find problem definition here. https://codility.com/programmers/challenges/

The key logic is using binary search to limit the answer area.

For each iteration of binary search, detail steps are written in the following code.

## Optimization for 100% solution

This problem is very time strict for java.

For large data set, my old answer which use many Collections always runs for 6+ seconds, but time limit is only 4 seconds.

So I replace almost all of them with array in heavy calculation part, to reduce time consuming of GC.

This results an 3+ seconds for each iteration of binary search.

https://codility.com/cert/view/certXKYPW7-D87MFQHQEGCKWRV9/details