{"id":"bc2fee16-03bf-4e86-971c-201226753ae9","name":"Lca - Lowest Common Ancestor","description":"<a href=\"https://www.spoj.com/problems/LCA/\">https://www.spoj.com/problems/LCA/</a>","inputFormat":".","outputFormat":".","constraints":".","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\nclass Main {\r\n static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\r\n static PrintWriter out = new PrintWriter(System.out);\r\n /*\r\n use in for reading input\r\n use out for printing output\r\n */\r\n\r\n public static void main(String[] args) throws IOException {\r\n\r\n // write your code here.\r\n\r\n\r\n\r\n out.close();\r\n }\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"1\r\n7\r\n3 2 3 4\r\n0\r\n3 5 6 7\r\n0\r\n0\r\n0\r\n0\r\n2\r\n5 7\r\n2 7","sampleOutput":"Case 1:\r\n3\r\n1","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ebd4bd7d-3745-4e3b-9603-da905237841b","name":"Binary Lifting For Experts","slug":"binary-lifting-for-experts-971","type":0},{"id":"c3e66693-4622-4eb6-aa76-1d162b164516","name":"Lca - Lowest Common Ancestor","slug":"lca-lowest-common-ancestor","type":1}],"next":{"id":"af6ecae1-53a9-4255-af7e-150e6b01dd94","name":"Cats And Tree","type":1,"slug":"cats-and-tree"},"prev":{"id":"bbdb8e13-0914-49d9-afd5-e8fa05d493e5","name":"K'th Ancestor","type":1,"slug":"k-th-ancestor"}}}

Lca - Lowest Common Ancestor

<a href="https://www.spoj.com/problems/LCA/">https://www.spoj.com/problems/LCA/</a>

{"id":"bc2fee16-03bf-4e86-971c-201226753ae9","name":"Lca - Lowest Common Ancestor","description":"<a href=\"https://www.spoj.com/problems/LCA/\">https://www.spoj.com/problems/LCA/</a>","inputFormat":".","outputFormat":".","constraints":".","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\nclass Main {\r\n static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\r\n static PrintWriter out = new PrintWriter(System.out);\r\n /*\r\n use in for reading input\r\n use out for printing output\r\n */\r\n\r\n public static void main(String[] args) throws IOException {\r\n\r\n // write your code here.\r\n\r\n\r\n\r\n out.close();\r\n }\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"1\r\n7\r\n3 2 3 4\r\n0\r\n3 5 6 7\r\n0\r\n0\r\n0\r\n0\r\n2\r\n5 7\r\n2 7","sampleOutput":"Case 1:\r\n3\r\n1","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ebd4bd7d-3745-4e3b-9603-da905237841b","name":"Binary Lifting For Experts","slug":"binary-lifting-for-experts-971","type":0},{"id":"c3e66693-4622-4eb6-aa76-1d162b164516","name":"Lca - Lowest Common Ancestor","slug":"lca-lowest-common-ancestor","type":1}],"next":{"id":"af6ecae1-53a9-4255-af7e-150e6b01dd94","name":"Cats And Tree","type":1,"slug":"cats-and-tree"},"prev":{"id":"bbdb8e13-0914-49d9-afd5-e8fa05d493e5","name":"K'th Ancestor","type":1,"slug":"k-th-ancestor"}}}
plane

Editor


Loading...

Lca - Lowest Common Ancestor

medium

https://www.spoj.com/problems/LCA/

Constraints

.

Format

Input

.

Output

.

Example

Sample Input

1 7 3 2 3 4 0 3 5 6 7 0 0 0 0 2 5 7 2 7

Sample Output

Case 1: 3 1

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode