27. Sum of Three Greatest per Group

Hard

df has a group column 'grps' and integer column 'vals'. For each group, return the sum of its three greatest values (as a Series indexed by group).

Sample data: df:

  grps  vals
0    a    12
1    a   345
2    a     3
3    b     1
4    b    45
5    c    14
... (15 rows total)
Implement solve(...)