To rack one's brains ∨ wits Meaning, Definition & Usage

Definitions
  1. to exert them to the utmost for the purpose of accomplishing something.

Webster 1913