bowang0911/leetcode huggingface dataset:
Paint House III

There is a row of `m` houses in a small city, each house must be painted with one of the `n` colors (labeled from `1` to `n`), some houses that have been painted last summer should not be painted again.

A neighborhood is a maximal group of continuous houses that are painted with the same color.

*   For example: `houses = [1,2,2,3,3,2,1,1]` contains `5` neighborhoods `[{1}, {2,2}, {3,3}, {2}, {1,1}]`.

Given an array `houses`, an `m x n` matrix `cost` and an integer `target` where:

*   `houses[i]`: is the color of the house `i`, and `0` if the house is not painted yet.
*   `cost[i][j]`: is the cost of paint the house `i` with the color `j + 1`.

Return _the minimum cost of painting all the remaining houses in such a way that there are exactly_ `target` _neighborhoods_. If it is not possible, return `-1`.

**Example 1:**

**Input:** houses = \[0,0,0,0,0\], cost = \[\[1,10\],\[10,1\],\[10,1\],\[1,10\],\[5,1\]\], m = 5, n = 2, target = 3
**Output:** 9
**Explanation:** Paint houses of this way \[1,2,2,1,1\]
This array contains target = 3 neighborhoods, \[{1}, {2,2}, {1,1}\].
Cost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.

**Example 2:**

**Input:** houses = \[0,2,1,2,0\], cost = \[\[1,10\],\[10,1\],\[10,1\],\[1,10\],\[5,1\]\], m = 5, n = 2, target = 3
**Output:** 11
**Explanation:** Some houses are already painted, Paint the houses of this way \[2,2,1,2,2\]
This array contains target = 3 neighborhoods, \[{2,2}, {1}, {2,2}\]. 
Cost of paint the first and last house (10 + 1) = 11.

**Example 3:**

**Input:** houses = \[3,1,2,3\], cost = \[\[1,1,1\],\[1,1,1\],\[1,1,1\],\[1,1,1\]\], m = 4, n = 3, target = 3
**Output:** -1
**Explanation:** Houses are already painted with a total of 4 neighborhoods \[{3},{1},{2},{3}\] different of target = 3.

**Constraints:**

*   `m == houses.length == cost.length`
*   `n == cost[i].length`
*   `1 <= m <= 100`
*   `1 <= n <= 20`
*   `1 <= target <= m`
*   `0 <= houses[i] <= n`
*   `1 <= cost[i][j] <= 104`
Delete N Nodes After M Nodes of a Linked List

You are given the `head` of a linked list and two integers `m` and `n`.

Traverse the linked list and remove some nodes in the following way:

*   Start with the head as the current node.
*   Keep the first `m` nodes starting with the current node.
*   Remove the next `n` nodes
*   Keep repeating steps 2 and 3 until you reach the end of the list.

Return _the head of the modified list after removing the mentioned nodes_.

**Example 1:**

**Input:** head = \[1,2,3,4,5,6,7,8,9,10,11,12,13\], m = 2, n = 3
**Output:** \[1,2,6,7,11,12\]
**Explanation:** Keep the first (m = 2) nodes starting from the head of the linked List  (1 ->2) show in black nodes.
Delete the next (n = 3) nodes (3 -> 4 -> 5) show in read nodes.
Continue with the same procedure until reaching the tail of the Linked List.
Head of the linked list after removing nodes is returned.

**Example 2:**

**Input:** head = \[1,2,3,4,5,6,7,8,9,10,11\], m = 1, n = 3
**Output:** \[1,5,9\]
**Explanation:** Head of linked list after removing nodes is returned.

**Constraints:**

*   The number of nodes in the list is in the range `[1, 104]`.
*   `1 <= Node.val <= 106`
*   `1 <= m, n <= 1000`

**Follow up:** Could you solve this problem by modifying the list in-place?
Final Prices With a Special Discount in a Shop

You are given an integer array `prices` where `prices[i]` is the price of the `ith` item in a shop.

There is a special discount for items in the shop. If you buy the `ith` item, then you will receive a discount equivalent to `prices[j]` where `j` is the minimum index such that `j > i` and `prices[j] <= prices[i]`. Otherwise, you will not receive any discount at all.

Return an integer array `answer` where `answer[i]` is the final price you will pay for the `ith` item of the shop, considering the special discount.

**Example 1:**

**Input:** prices = \[8,4,6,2,3\]
**Output:** \[4,2,4,2,3\]
**Explanation:** 
For item 0 with price\[0\]=8 you will receive a discount equivalent to prices\[1\]=4, therefore, the final price you will pay is 8 - 4 = 4.
For item 1 with price\[1\]=4 you will receive a discount equivalent to prices\[3\]=2, therefore, the final price you will pay is 4 - 2 = 2.
For item 2 with price\[2\]=6 you will receive a discount equivalent to prices\[3\]=2, therefore, the final price you will pay is 6 - 2 = 4.
For items 3 and 4 you will not receive any discount at all.

**Example 2:**

**Input:** prices = \[1,2,3,4,5\]
**Output:** \[1,2,3,4,5\]
**Explanation:** In this case, for all items, you will not receive any discount at all.

**Example 3:**

**Input:** prices = \[10,1,1,6\]
**Output:** \[9,0,1,6\]

**Constraints:**

*   `1 <= prices.length <= 500`
*   `1 <= prices[i] <= 1000`

The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees must also be binary search trees.
Subrectangle Queries

Implement the class `SubrectangleQueries` which receives a `rows x cols` rectangle as a matrix of integers in the constructor and supports two methods:

1. `updateSubrectangle(int row1, int col1, int row2, int col2, int newValue)`

*   Updates all values with `newValue` in the subrectangle whose upper left coordinate is `(row1,col1)` and bottom right coordinate is `(row2,col2)`.

2. `getValue(int row, int col)`

*   Returns the current value of the coordinate `(row,col)` from the rectangle.

**Example 1:**

**Input**
\[ "SubrectangleQueries ", "getValue ", "updateSubrectangle ", "getValue ", "getValue ", "updateSubrectangle ", "getValue ", "getValue "\]
\[\[\[\[1,2,1\],\[4,3,4\],\[3,2,1\],\[1,1,1\]\]\],\[0,2\],\[0,0,3,2,5\],\[0,2\],\[3,1\],\[3,0,3,2,10\],\[3,1\],\[0,2\]\]
**Output**
\[null,1,null,5,5,null,10,5\]
**Explanation**
SubrectangleQueries subrectangleQueries = new SubrectangleQueries(\[\[1,2,1\],\[4,3,4\],\[3,2,1\],\[1,1,1\]\]);  
// The initial rectangle (4x3) looks like:
// 1 2 1
// 4 3 4
// 3 2 1
// 1 1 1
subrectangleQueries.getValue(0, 2); // return 1
subrectangleQueries.updateSubrectangle(0, 0, 3, 2, 5);
// After this update the rectangle looks like:
// 5 5 5
// 5 5 5
// 5 5 5
// 5 5 5 
subrectangleQueries.getValue(0, 2); // return 5
subrectangleQueries.getValue(3, 1); // return 5
subrectangleQueries.updateSubrectangle(3, 0, 3, 2, 10);
// After this update the rectangle looks like:
// 5   5   5
// 5   5   5
// 5   5   5
// 10  10  10 
subrectangleQueries.getValue(3, 1); // return 10
subrectangleQueries.getValue(0, 2); // return 5

**Example 2:**

**Input**
\[ "SubrectangleQueries ", "getValue ", "updateSubrectangle ", "getValue ", "getValue ", "updateSubrectangle ", "getValue "\]
\[\[\[\[1,1,1\],\[2,2,2\],\[3,3,3\]\]\],\[0,0\],\[0,0,2,2,100\],\[0,0\],\[2,2\],\[1,1,2,2,20\],\[2,2\]\]
**Output**
\[null,1,null,100,100,null,20\]
**Explanation**
SubrectangleQueries subrectangleQueries = new SubrectangleQueries(\[\[1,1,1\],\[2,2,2\],\[3,3,3\]\]);
subrectangleQueries.getValue(0, 0); // return 1
subrectangleQueries.updateSubrectangle(0, 0, 2, 2, 100);
subrectangleQueries.getValue(0, 0); // return 100
subrectangleQueries.getValue(2, 2); // return 100
subrectangleQueries.updateSubrectangle(1, 1, 2, 2, 20);
subrectangleQueries.getValue(2, 2); // return 20

**Constraints:**

*   There will be at most `500` operations considering both methods: `updateSubrectangle` and `getValue`.
*   `1 <= rows, cols <= 100`
*   `rows == rectangle.length`
*   `cols == rectangle[i].length`
*   `0 <= row1 <= row2 < rows`
*   `0 <= col1 <= col2 < cols`
*   `1 <= newValue, rectangle[i][j] <= 10^9`
*   `0 <= row < rows`
*   `0 <= col < cols`
Find Two Non-overlapping Sub-arrays Each With Target Sum

You are given an array of integers `arr` and an integer `target`.

You have to find **two non-overlapping sub-arrays** of `arr` each with a sum equal `target`. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is **minimum**.

Return _the minimum sum of the lengths_ of the two required sub-arrays, or return `-1` if you cannot find such two sub-arrays.

**Example 1:**

**Input:** arr = \[3,2,2,4,3\], target = 3
**Output:** 2
**Explanation:** Only two sub-arrays have sum = 3 (\[3\] and \[3\]). The sum of their lengths is 2.

**Example 2:**

**Input:** arr = \[7,3,4,7\], target = 7
**Output:** 2
**Explanation:** Although we have three non-overlapping sub-arrays of sum = 7 (\[7\], \[3,4\] and \[7\]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.

**Example 3:**

**Input:** arr = \[4,3,2,6,2,3,4\], target = 6
**Output:** -1
**Explanation:** We have only one sub-array of sum = 6.

**Constraints:**

*   `1 <= arr.length <= 105`
*   `1 <= arr[i] <= 1000`
*   `1 <= target <= 108`
Allocate Mailboxes

Given the array `houses` where `houses[i]` is the location of the `ith` house along a street and an integer `k`, allocate `k` mailboxes in the street.

Return _the **minimum** total distance between each house and its nearest mailbox_.

The test cases are generated so that the answer fits in a 32-bit integer.

**Example 1:**

**Input:** houses = \[1,4,8,10,20\], k = 3
**Output:** 5
**Explanation:** Allocate mailboxes in position 3, 9 and 20.
Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 

**Example 2:**

**Input:** houses = \[2,3,5,12,18\], k = 2
**Output:** 9
**Explanation:** Allocate mailboxes in position 3 and 14.
Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.

**Constraints:**

*   `1 <= k <= houses.length <= 100`
*   `1 <= houses[i] <= 104`
*   All the integers of `houses` are **unique**.
Running Sum of 1d Array

Given an array `nums`. We define a running sum of an array as `runningSum[i] = sum(nums[0]...nums[i])`.

Return the running sum of `nums`.

**Example 1:**

**Input:** nums = \[1,2,3,4\]
**Output:** \[1,3,6,10\]
**Explanation:** Running sum is obtained as follows: \[1, 1+2, 1+2+3, 1+2+3+4\].

**Example 2:**

**Input:** nums = \[1,1,1,1,1\]
**Output:** \[1,2,3,4,5\]
**Explanation:** Running sum is obtained as follows: \[1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1\].

**Example 3:**

**Input:** nums = \[3,1,2,10,1\]
**Output:** \[3,4,6,16,17\]

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `-10^6 <= nums[i] <= 10^6`
Least Number of Unique Integers after K Removals

Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.**

**Example 1:**

**Input:** arr = \[5,5,4\], k = 1
**Output:** 1
**Explanation**: Remove the single 4, only 5 is left.

**Example 2:**

**Input:** arr = \[4,3,1,1,3,3,2\], k = 3
**Output:** 2
**Explanation**: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.

**Constraints:**

*   `1 <= arr.length <= 10^5`
*   `1 <= arr[i] <= 10^9`
*   `0 <= k <= arr.length`
Minimum Number of Days to Make m Bouquets

You are given an integer array `bloomDay`, an integer `m` and an integer `k`.

You want to make `m` bouquets. To make a bouquet, you need to use `k` **adjacent flowers** from the garden.

The garden consists of `n` flowers, the `ith` flower will bloom in the `bloomDay[i]` and then can be used in **exactly one** bouquet.

Return _the minimum number of days you need to wait to be able to make_ `m` _bouquets from the garden_. If it is impossible to make m bouquets return `-1`.

**Example 1:**

**Input:** bloomDay = \[1,10,3,10,2\], m = 3, k = 1
**Output:** 3
**Explanation:** Let us see what happened in the first three days. x means flower bloomed and \_ means flower did not bloom in the garden.
We need 3 bouquets each should contain 1 flower.
After day 1: \[x, \_, \_, \_, \_\]   // we can only make one bouquet.
After day 2: \[x, \_, \_, \_, x\]   // we can only make two bouquets.
After day 3: \[x, \_, x, \_, x\]   // we can make 3 bouquets. The answer is 3.

**Example 2:**

**Input:** bloomDay = \[1,10,3,10,2\], m = 3, k = 2
**Output:** -1
**Explanation:** We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.

**Example 3:**

**Input:** bloomDay = \[7,7,7,7,12,7,7\], m = 2, k = 3
**Output:** 12
**Explanation:** We need 2 bouquets each should have 3 flowers.
Here is the garden after the 7 and 12 days:
After day 7: \[x, x, x, x, \_, x, x\]
We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
After day 12: \[x, x, x, x, x, x, x\]
It is obvious that we can make two bouquets in different ways.

**Constraints:**

*   `bloomDay.length == n`
*   `1 <= n <= 105`
*   `1 <= bloomDay[i] <= 109`
*   `1 <= m <= 106`
*   `1 <= k <= n`
Kth Ancestor of a Tree Node

You are given a tree with `n` nodes numbered from `0` to `n - 1` in the form of a parent array `parent` where `parent[i]` is the parent of `ith` node. The root of the tree is node `0`. Find the `kth` ancestor of a given node.

The `kth` ancestor of a tree node is the `kth` node in the path from that node to the root node.

Implement the `TreeAncestor` class:

*   `TreeAncestor(int n, int[] parent)` Initializes the object with the number of nodes in the tree and the parent array.
*   `int getKthAncestor(int node, int k)` return the `kth` ancestor of the given node `node`. If there is no such ancestor, return `-1`.

**Example 1:**

**Input**
\[ "TreeAncestor ",  "getKthAncestor ",  "getKthAncestor ",  "getKthAncestor "\]
\[\[7, \[-1, 0, 0, 1, 1, 2, 2\]\], \[3, 1\], \[5, 2\], \[6, 3\]\]
**Output**
\[null, 1, 0, -1\]

**Explanation**
TreeAncestor treeAncestor = new TreeAncestor(7, \[-1, 0, 0, 1, 1, 2, 2\]);
treeAncestor.getKthAncestor(3, 1); // returns 1 which is the parent of 3
treeAncestor.getKthAncestor(5, 2); // returns 0 which is the grandparent of 5
treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancestor

**Constraints:**

*   `1 <= k <= n <= 5 * 104`
*   `parent.length == n`
*   `parent[0] == -1`
*   `0 <= parent[i] < n` for all `0 < i < n`
*   `0 <= node < n`
*   There will be at most `5 * 104` queries.
Clone Binary Tree With Random Pointer

A binary tree is given such that each node contains an additional random pointer which could point to any node in the tree or null.

Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the tree.

The tree is represented in the same input/output way as normal binary trees where each node is represented as a pair of `[val, random_index]` where:

*   `val`: an integer representing `Node.val`
*   `random_index`: the index of the node (in the input) where the random pointer points to, or `null` if it does not point to any node.

You will be given the tree in class `Node` and you should return the cloned tree in class `NodeCopy`. `NodeCopy` class is just a clone of `Node` class with the same attributes and constructors.

**Example 1:**

**Input:** root = \[\[1,null\],null,\[4,3\],\[7,0\]\]
**Output:** \[\[1,null\],null,\[4,3\],\[7,0\]\]
**Explanation:** The original binary tree is \[1,null,4,7\].
The random pointer of node one is null, so it is represented as \[1, null\].
The random pointer of node 4 is node 7, so it is represented as \[4, 3\] where 3 is the index of node 7 in the array representing the tree.
The random pointer of node 7 is node 1, so it is represented as \[7, 0\] where 0 is the index of node 1 in the array representing the tree.

**Example 2:**

**Input:** root = \[\[1,4\],null,\[1,0\],null,\[1,5\],\[1,5\]\]
**Output:** \[\[1,4\],null,\[1,0\],null,\[1,5\],\[1,5\]\]
**Explanation:** The random pointer of a node can be the node itself.

**Example 3:**

**Input:** root = \[\[1,6\],\[2,5\],\[3,4\],\[4,3\],\[5,2\],\[6,1\],\[7,0\]\]
**Output:** \[\[1,6\],\[2,5\],\[3,4\],\[4,3\],\[5,2\],\[6,1\],\[7,0\]\]

**Constraints:**

*   The number of nodes in the `tree` is in the range `[0, 1000].`
*   `1 <= Node.val <= 106`
XOR Operation in an Array

You are given an integer `n` and an integer `start`.

Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`.

Return _the bitwise XOR of all elements of_ `nums`.

**Example 1:**

**Input:** n = 5, start = 0
**Output:** 8
**Explanation:** Array nums is equal to \[0, 2, 4, 6, 8\] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
Where  "^ " corresponds to bitwise XOR operator.

**Example 2:**

**Input:** n = 4, start = 3
**Output:** 8
**Explanation:** Array nums is equal to \[3, 5, 7, 9\] where (3 ^ 5 ^ 7 ^ 9) = 8.

**Constraints:**

*   `1 <= n <= 1000`
*   `0 <= start <= 1000`
*   `n == nums.length`
Making File Names Unique

Given an array of strings `names` of size `n`. You will create `n` folders in your file system **such that**, at the `ith` minute, you will create a folder with the name `names[i]`.

Since two files **cannot** have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of `(k)`, where, `k` is the **smallest positive integer** such that the obtained name remains unique.

Return _an array of strings of length_ `n` where `ans[i]` is the actual name the system will assign to the `ith` folder when you create it.

**Example 1:**

**Input:** names = \[ "pes ", "fifa ", "gta ", "pes(2019) "\]
**Output:** \[ "pes ", "fifa ", "gta ", "pes(2019) "\]
**Explanation:** Let's see how the file system creates folder names:
 "pes " --> not assigned before, remains  "pes "
 "fifa " --> not assigned before, remains  "fifa "
 "gta " --> not assigned before, remains  "gta "
 "pes(2019) " --> not assigned before, remains  "pes(2019) "

**Example 2:**

**Input:** names = \[ "gta ", "gta(1) ", "gta ", "avalon "\]
**Output:** \[ "gta ", "gta(1) ", "gta(2) ", "avalon "\]
**Explanation:** Let's see how the file system creates folder names:
 "gta " --> not assigned before, remains  "gta "
 "gta(1) " --> not assigned before, remains  "gta(1) "
 "gta " --> the name is reserved, system adds (k), since  "gta(1) " is also reserved, systems put k = 2. it becomes  "gta(2) "
 "avalon " --> not assigned before, remains  "avalon "

**Example 3:**

**Input:** names = \[ "onepiece ", "onepiece(1) ", "onepiece(2) ", "onepiece(3) ", "onepiece "\]
**Output:** \[ "onepiece ", "onepiece(1) ", "onepiece(2) ", "onepiece(3) ", "onepiece(4) "\]
**Explanation:** When the last folder is created, the smallest positive valid k is 4, and it becomes  "onepiece(4) ".

**Constraints:**

*   `1 <= names.length <= 5 * 104`
*   `1 <= names[i].length <= 20`
*   `names[i]` consists of lowercase English letters, digits, and/or round brackets.
Avoid Flood in The City

Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the `nth` lake, the `nth` lake becomes full of water. If it rains over a lake that is **full of water**, there will be a **flood**. Your goal is to avoid floods in any lake.

Given an integer array `rains` where:

*   `rains[i] > 0` means there will be rains over the `rains[i]` lake.
*   `rains[i] == 0` means there are no rains this day and you can choose **one lake** this day and **dry it**.

Return _an array `ans`_ where:

*   `ans.length == rains.length`
*   `ans[i] == -1` if `rains[i] > 0`.
*   `ans[i]` is the lake you choose to dry in the `ith` day if `rains[i] == 0`.

If there are multiple valid answers return **any** of them. If it is impossible to avoid flood return **an empty array**.

Notice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes.

**Example 1:**

**Input:** rains = \[1,2,3,4\]
**Output:** \[-1,-1,-1,-1\]
**Explanation:** After the first day full lakes are \[1\]
After the second day full lakes are \[1,2\]
After the third day full lakes are \[1,2,3\]
After the fourth day full lakes are \[1,2,3,4\]
There's no day to dry any lake and there is no flood in any lake.

**Example 2:**

**Input:** rains = \[1,2,0,0,2,1\]
**Output:** \[-1,-1,2,1,-1,-1\]
**Explanation:** After the first day full lakes are \[1\]
After the second day full lakes are \[1,2\]
After the third day, we dry lake 2. Full lakes are \[1\]
After the fourth day, we dry lake 1. There is no full lakes.
After the fifth day, full lakes are \[2\].
After the sixth day, full lakes are \[1,2\].
It is easy that this scenario is flood-free. \[-1,-1,1,2,-1,-1\] is another acceptable scenario.

**Example 3:**

**Input:** rains = \[1,2,0,1,2\]
**Output:** \[\]
**Explanation:** After the second day, full lakes are  \[1,2\]. We have to dry one lake in the third day.
After that, it will rain over lakes \[1,2\]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.

**Constraints:**

*   `1 <= rains.length <= 105`
*   `0 <= rains[i] <= 109`
Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

Given a weighted undirected connected graph with `n` vertices numbered from `0` to `n - 1`, and an array `edges` where `edges[i] = [ai, bi, weighti]` represents a bidirectional and weighted edge between nodes `ai` and `bi`. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.

Find _all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST)_. An MST edge whose deletion from the graph would cause the MST weight to increase is called a _critical edge_. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.

Note that you can return the indices of the edges in any order.

**Example 1:**

**Input:** n = 5, edges = \[\[0,1,1\],\[1,2,1\],\[2,3,2\],\[0,3,2\],\[0,4,3\],\[3,4,3\],\[1,4,6\]\]
**Output:** \[\[0,1\],\[2,3,4,5\]\]
**Explanation:** The figure above describes the graph.
The following figure shows all the possible MSTs:
 
Notice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.
The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.

**Example 2:**

**Input:** n = 4, edges = \[\[0,1,1\],\[1,2,1\],\[2,3,1\],\[0,3,1\]\]
**Output:** \[\[\],\[0,1,2,3\]\]
**Explanation:** We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.

**Constraints:**

*   `2 <= n <= 100`
*   `1 <= edges.length <= min(200, n * (n - 1) / 2)`
*   `edges[i].length == 3`
*   `0 <= ai < bi < n`
*   `1 <= weighti <= 1000`
*   All pairs `(ai, bi)` are **distinct**.
Clone N-ary Tree

Given a `root` of an N-ary tree, return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the tree.

Each node in the n-ary tree contains a val (`int`) and a list (`List[Node]`) of its children.

class Node {
    public int val;
    public List children;
}

_Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples)._

**Example 1:**

**Input:** root = \[1,null,3,2,4,null,5,6\]
**Output:** \[1,null,3,2,4,null,5,6\]

**Example 2:**

**Input:** root = \[1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14\]
**Output:** \[1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14\]

**Constraints:**

*   The depth of the n-ary tree is less than or equal to `1000`.
*   The total number of nodes is between `[0, 104]`.

**Follow up:** Can your solution work for the [graph problem](https://leetcode.com/problems/clone-graph/)?