One of the main goals of the Long Baseline Neutrino Oscillation experiment (LBNO) experiment is to study the L/E behaviour of the electron neutrino appearance probability in order to determine the unknown phase $delta_{CP}$. In the standard neutrino 3-flavour mixing paradigm, this parameter encapsulates a possibility of a CP violation in the lepton sector that in turn could help explain the matter-antimatter asymmetry in the universe. In LBNO, the measurement of $delta_{CP}$ would rely on the observation of the electron appearance probability in a broad energy range covering the 1$^{st}$ and 2$^{nd}$ maxima of the oscillation probability. An optimization of the energy spectrum of the neutrino beam is necessary to find the best coverage of the neutrino energies of interest. This in general is a complex task that requires exploring a large parameter space describing hadron target and beamline focusing elements. In this paper we will present a numerical approach of finding a solution to this difficult optimization problem often encountered in design of modern neutrino beamlines and we will show the improved LBNO sensitivity to the presence of the leptonic CP violation attained after the neutrino beam optimization.