Add #40 C solution