How can I place a camera high enough that it can see the entire level?

I apologize ahead of time for my lack of math.
I’m trying to get a camera looking down at my dungeon level so it sees the entire level at once, no matter what size the dungeon is.
I am making a randomly generated dungeon, right now all on one z plane. Once my generation is done I use the lowest and highest x-y values and get the vector length between them. I guessed (ha) that because the camera has a 90 degree field of vision I have a right triangle. That means the height to see the edges is half the length across the dungeon. So I place the camera that high with 20% more so there’s a nice border.
Sometimes it works, but sometimes it doesn’t!
I’ve realized that I have to contend with the vertical pov not just the horizontal. Reading up on UE 5 cameras, and just cameras in general. Still I’d be happy to have any tips!