Company: BNY_18nov
Difficulty: medium
Minimize Tree Diameter Problem Description You are given an undirected tree and are allowed to perform up to k operations on it. In each operation, you can remove a leaf vertex (a vertex connected to exactly one other vertex) and its adjacent edge. Your goal is to minimize the tree's diameter by applying these operations optimally. The distance between two vertices is measured by the number of edges in the shortest path between them. The diameter of a tree is defined as the maximum distance between any pair of vertices in the tree. Return the smallest possible diameter after performing at most k operations. Complete the function treeCut in the editor with the following parameter(s): int n: the number of vertices in the tree int k: the number of operations that can be deleted int edges[n-1][2]: a 2d array of connected vertices int treeCut(int n, int k, vector > edges) { // Function implementation } Examples Example 1: Input: n = 5, k = 2, edges = [[0, 1], [2, 1], [4, 1], [2, 3]] Output: