Mobile impurity in a one-dimensional quantum gas: Exact diagonalization in the Bethe Ansatz basis