We present an efficient, unconditionally stable, and accurate numerical method for the solution of the Gross-Pitaevskii equation. We begin with an introduction on the gradient flow with discrete normalization (GFDN) for computing stationary states of a nonconvex minimization problem. Then we present a new numerical method, CFDM-AIF method, which combines compact finite difference method (CFDM) in space and array-representation integration factor (AIF) method in time. The key features of our methods are as follows: (i) the fourth-order accuracy in space andrth (r≥2) accuracy in time which can be achieved and (ii) the significant reduction of storage and CPU cost because of array-representation technique for efficient handling of exponential matrices. The CFDM-AIF method is implemented to investigate the ground and first excited state solutions of the Gross-Pitaevskii equation in two-dimensional (2D) and three-dimensional (3D) Bose-Einstein condensates (BECs). Numerical results are presented to demonstrate the validity, accuracy, and efficiency of the CFDM-AIF method.