Java Algorithm Practice