if its at d, then you will have to consider the balls as sphere and find respective potentials at a distance of d for each ball
Here D<<r signifies the ball can be considered as point charges, since for point charge potential is same at all distance, the distance D did not matter and hence its not a part of final answer, in case d is not small then it will be a part of final answer