The work done by gravity is $-mgL$ in both cases.
Work Step by Step
We know that gravity is a conservative force. Though the idea of conservative vector fields is something you will touch far more in vector calculus, the consequence is that the potential energy is path independent. In other words, it does not matter what path you take; what matters is where you start and where you end up. Thus, we can use the simple formula, U=mgh, to see that the change in potential energy is $-mgL.$