Rakuten Interview Question

basics question from java and algorithms