The inverse problem in the calculus of variations via exterior differential systems