How to find LCA using dfs?

Can you please show me the code to find LCA using dfs.

FInd sample code for the same here