Multihop device-to-device (D2D) communication is a promising advancement since it allows wireless users in close proximity to communicate directly with one another without using base stations (BSs). With two nearby users, this technology intends to keep up with the accelerating development of mobile devices and the rising demands of local traffic loads. High-data-rate shortrange transmission is made possible by this paradigm, which also lowers network backhaul expenses while improving end-user experience, spectral efficiency (SE) and network coverage. In order to maximize the cell's overall sum rates, this article examines the problem of selecting the optimal M-D2D linkages and cellular users (CUs) to form spectrum-sharing partners while taking quality of service (QoS) and energy efficiency (EE) needs into consideration.This study examines the use of a channel assignment system and a power allocation technique to manage interference in D2D communication scenarios involving many hops (more than one hop). The suggested channel assignment approach is based on the Hungarian method, but the power allocation system is based on the time-efficient enhanced Harris hawks optimization (HHO) and red fox (RF) algorithms. A genetic algorithm (GA)-based methodology and various baseline approaches are used to compare the effectiveness of the suggested system. Because it combines exploitation and exploration using a memory-based local search methodology and a perturbation mechanism, the suggested approach outperforms the GA in simulations. The results clearly demonstrate that the suggested method increases EE by up to 13% by producing the appropriate channel and power assignment for CUs and M-D2D users.