Machine learning based on artificial neural networks has emerged as an efficient means to develop empirical models of complex systems. Recently, inverse design has been used to design optical devices using artificial intelligence (AI). In many fields, this method predicts intuitive designs to non-intuitive designs, and then shows the most optimized design that can be applied to the desired application. Especially, it has beenextended to the field of nanophotonics. However, since the nanostructure in the terahertz (THz) region is over ten thousand times smaller than the wavelengths, more computation resources are required than in the visible to infrared region. In our work, the inverse design method based on deep Q learning combined with modal expansion method is used to obtain optimized structural designs of the micron- to nano-gap array working at THz frequencies. Actually, It is more than 1000 times faster than using a conventional numerical simulation method for inverse design. To verify the optimized results, we performed numerical simulations using finite element method and experimental measurements using THz time-domain spectroscopy. With our inverse design method based on the analytical solution, computational resources can be significantly reduced, making it an alternative to the numerical simulation-based inverse design, which was unfeasible due to the mass computation time.