Aera Technology interview question

Leetcode Medium questions for the OA