Samsung Electronics interview question

Calculate area type algorithm question.