About the algorithm The algorithm passed on half of the tests, but "failed" on others due timeout. Still working on it.