Spoilers
Akane and Junpei are linked via the morphogenetic field due to their childhood friendship. This connection allows them to communicate with each other similar to how telepathy works, except that it can cross time as well as distance. This ability gets stronger whenever someone is in great danger or when they experience a flash of insight.
During the First Nonary Game, Akane uses the morphogenetic field to communicate with Junpei in the future when she cannot solve the Sudoku puzzle in the incinerator. She is in great danger and he (in the future) is experiencing a flash of insight (regarding both the revelation about why he has been included in the Second Nonary Game and the solution to the Sudoku puzzle).
This makes the ability for Akane and Junpei to communicate even stronger (which makes up for the fact that they gave grown somewhat distant by the time of the First Nonary Game, as well as for the fact that they are communicating across time). And so Junpei is able to send the solution back in time to Akane, who survives the First Nonary Game.
This is the true timeline. In order to prevent a time paradox from occurring, Akane becomes Zero and sets up the Second Nonary Game to make sure that Junpei solves the puzzle and sends her the solution in the past. It is only in alternate timelines where Junpei fails that Akane dies. In the true timeline, Akane survives.