The charge-flipping algorithm in its band-flipping variant is capable of ab initio reconstructions of scattering densities with positive and negative values. It is shown that the method can be applied to reconstructions of difference electron densities of superstructures, i.e. densities obtained as a difference between the true scattering density and the average density over two or more subcells of the true structure. The amplitudes of reflections lying on the reciprocal lattice of the subcell are not required for the procedure. A series of examples shows applications of the method to the solution of superstructures in periodic crystals or quasicrystals as well as the application to ab initio solution of modulation of an incommensurately modulated structure from satellite reflections only and solution of a structure from a crystal twinned by reticular pseudomerohedry. The method is especially suited for solving pseudosymmetry problems occurring frequently in superstructures.