Optimal Algorithms for the Inhomogeneous Spiked Wigner model