Pergunta de entrevista da empresa Samsung Electronics

Calculate area type algorithm question.