  The hidden subgroup problem~(HSP) is one of the most important problems in
quantum computation. Many problems for which quantum algorithm achieves
exponential speedup over its classical counterparts can be reduced to the
Abelian HSP. However, there is no efficient quantum algorithm for solving the
non-Abelian HSP. We find that the HSP can be reduced to a nested structured
search problem that is solved efficiently by using a quantum algorithm via
multistep quantum computation. Then we solve the HSP and problems that can be
reduced to both the Abelian and the non-Abelian HSP in polynomial time by using
this algorithm.
