Deloitte interview question

Based on sql and basic dsa