Company: Linkedin_31aug
Difficulty: medium
Minimum Operations to Make Array a Tree Problem Description In Hackerland, a town can be represented as a tree graph. An array arr can represent a town if: There exists exactly one index i such that arr[i] == -1 (representing the root node). If we create a graph of n nodes such that node arr[i] is connected to node i (with 1-based indexing), then the graph forms a tree. Given an adjacency list arr of n integers, you can change arr[i] to any integer in one operation. Find the minimum number of operations required to make the array represent a town of Hackerland. Complete the function findMinOperations in the editor with the following parameter: int arr[n] : the parents of each node Returns int : the minimum number of operations required to make arr a tree Examples Example 1: Input: arr = [2,1,3] Output: 2 Explanation: Change arr[0] to 3 and arr[2] to -1. The final array is [3, 1, -1] . Node 3 is the root of the tree since arr[2] (which corresponds to node 3 in 1-based indexing) is -1. T