From the Super Mario Wiki
The fight is similar to Level 6-DK, except the bottom Direction Switch is placed lower and there is a Springboard rather than a ladder. Donkey Kong begins by tossing a Bob-omb up onto the highest conveyor, and the Bob-omb will begin to move down them. If a Bob-omb falls onto the second conveyor and is facing left, there is a small hole it can fit through to reach the player. In order to damage Donkey Kong, the player needs to press Direction Switches to keep the Bob-omb from going into the hole and to make it fall onto Donkey Kong before it blows up. However, there are several lasers that alternate around the Direction Switches and Donkey Kong has a Direction Switch of his own that he will use to keep the Bob-ombs away from him. Making four Bob-ombs fall onto Donkey Kong will defeat him.