The standard algorithm is this:
Hold your hald on the right wall at all times and keep walking forward.
However, this only works in mazes where the exits are both on the outside and either you use it from the beginning or there are no disconnected parts.
Another one that works if you're allowed to use markings:
When you get to an unmarked junction, mark the path you entered by, then pick a random path. If you're going forward and you reach a junction wih a single mark somewhere, double mark that branch and turn back. If you reach a dead end, turn back and make a double mark. If you run out of possibilities, go back down the single marked path and add another mark on your way back. Treat all double marks as walls.