Works but not accepted by Hackerrank.