java version for two sum problem