Pergunta de entrevista da empresa Grid Dynamics

L1 asked to write a java code for the scenario