r sum based on two columns

Solutions on MaxInterview for r sum based on two columns by the best coders in the world