Su practice Java algorithm