RippleHire Interview Question

Logic based java question