Surface nanobubbles are nanoscopic spherical-cap shaped gaseous domains on immersed substrates which are stable, even for days. After the stability of a single surface nanobubble has been theoretically explained, i.e. contact line pinning and gas oversaturation are required to stabilize it against diffusive dissolution [Lohse and Zhang, Phys. Rev. E, 2015, 91, 031003(R)], here we focus on the collective diffusive interaction of multiple nanobubbles. For that purpose we develop a finite difference scheme for the diffusion equation with the appropriate boundary conditions and with the immersed boundary method used to represent the growing or shrinking bubbles. After validation of the scheme against the exact results of Epstein and Plesset for a bulk bubble [J. Chem. Phys., 1950, 18, 1505] and of Lohse and Zhang for a surface bubble, the framework of these simulations is used to describe the coarsening process of competitively growing nanobubbles. The coarsening process for such diffusively interacting nanobubbles slows down with advancing time and increasing bubble distance. The present results for surface nanobubbles are also applicable for immersed surface nanodroplets, for which better controlled experimental results of the coarsening process exist.