Both answers are correct as shown in English Grammar in-usewith the same examples:
Note that in this structure
no sooner introduces the event that occurred first.
- No sooner had I arrived at the station than the train came. (= I came first and the train arrived right after me.)
- No sooner had we heard the noise than we rushed to the spot.
- No sooner had she finished one project than she started working on the next.
- No sooner had I closed my eyes than I fell asleep.
Note that
did is also possible in this structure.
- No sooner did I arrive at the station than the train came.
- No sooner did we hear the noise than we rushed to the spot