I am reading a Gambler's ruin probability question but do not really understand difference equation. So I am reading the link here:https://www.cl.cam.ac.uk/teaching/2003/Probability/prob07.pdf
I understand how to get the two roots of $w_1$ and $w_2$. But I don't understand the below process:

What $A_1$ and what $A_2$ are we doing here, and why do we do so?
Also how does the author conclude that the general solution is below:

It seems the author is skipping several key reasoning and I just don't follow the steps here..
