Domanda di colloquio di Amazon

How would you calculate these statistics (e.g. group wise mean) without a loop?