ZapCom Group interview question

Adding triplets from array problem.