Skip to content

Instantly share code, notes, and snippets.

@luccasiau
Created May 9, 2015 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luccasiau/2faaf8fe1bb3af57c558 to your computer and use it in GitHub Desktop.
Save luccasiau/2faaf8fe1bb3af57c558 to your computer and use it in GitHub Desktop.
LCA(vértice a, vértice b):
enquanto (a != b):
se (nivel[a] > nivel[b]) a = pai[a]
senao b = pai[b]
retorna a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment