4th Bit Hackerrank Solution Java