We present a master-equation approach to the narrow-escape-time (NET) problem, i.e., the time needed for a particle contained in a confining domain with a single small or narrow opening to exit the domain. In this paper we introduce an alternative type of confining domain (to the usually spherical one) and we consider the diffusion process on a lattice rather than in continuous space. We have obtained analytic results for the basic quantity studied in the NET problem, the mean first-passage time, and we have studied its dependence in terms of the transition (desorption) probability over (from) the surface boundary and the confining domain dimensions. In addition to our analytical approach, we have implemented Monte Carlo simulations, finding excellent agreement between the theoretical results and simulations.