Company: Curefit
Difficulty: medium
Minimum Distance with Special Nodes Problem Description You have a tree consisting of N nodes. There are K number of special nodes in the tree. You can perform exactly one operation: add an edge between any two special nodes. Find the minimum distance between node 1 and node N that you can obtain after performing this operation exactly once. Function description: Complete the solve() function. The function takes the following 5 parameters and returns a single integer denoting the answer to the question. N: represents the number of nodes in the tree K: represents the number of special nodes special_nodes: represents the array containing the special nodes node_from: represents the array denoting the starting node of each edge node_to: represents the array denoting the ending node of each edge Output format: For each testcase print a single integer representing the minimum distance between node 1 and node N. Examples Example 1: Input: 2 6 2 6 3 2 3 3 5 4 1 1 4 3 6 7 3 6 4 3 2 1 4 2 4 1 3