bowang0911/leetcode huggingface dataset:
Number of Provinces

There are `n` cities. Some of them are connected, while some are not. If city `a` is connected directly with city `b`, and city `b` is connected directly with city `c`, then city `a` is connected indirectly with city `c`.

A **province** is a group of directly or indirectly connected cities and no other cities outside of the group.

You are given an `n x n` matrix `isConnected` where `isConnected[i][j] = 1` if the `ith` city and the `jth` city are directly connected, and `isConnected[i][j] = 0` otherwise.

Return _the total number of **provinces**_.

**Example 1:**

**Input:** isConnected = \[\[1,1,0\],\[1,1,0\],\[0,0,1\]\]
**Output:** 2

**Example 2:**

**Input:** isConnected = \[\[1,0,0\],\[0,1,0\],\[0,0,1\]\]
**Output:** 3

**Constraints:**

*   `1 <= n <= 200`
*   `n == isConnected.length`
*   `n == isConnected[i].length`
*   `isConnected[i][j]` is `1` or `0`.
*   `isConnected[i][i] == 1`
*   `isConnected[i][j] == isConnected[j][i]`
Split Array with Equal Sum

Given an integer array `nums` of length `n`, return `true` if there is a triplet `(i, j, k)` which satisfies the following conditions:

*   `0 < i, i + 1 < j, j + 1 < k < n - 1`
*   The sum of subarrays `(0, i - 1)`, `(i + 1, j - 1)`, `(j + 1, k - 1)` and `(k + 1, n - 1)` is equal.

A subarray `(l, r)` represents a slice of the original array starting from the element indexed `l` to the element indexed `r`.

**Example 1:**

**Input:** nums = \[1,2,1,2,1,2,1\]
**Output:** true
**Explanation:**
i = 1, j = 3, k = 5. 
sum(0, i - 1) = sum(0, 0) = 1
sum(i + 1, j - 1) = sum(2, 2) = 1
sum(j + 1, k - 1) = sum(4, 4) = 1
sum(k + 1, n - 1) = sum(6, 6) = 1

**Example 2:**

**Input:** nums = \[1,2,1,2,1,2,1,2\]
**Output:** false

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 2000`
*   `-106 <= nums[i] <= 106`
Binary Tree Longest Consecutive Sequence II

Given the `root` of a binary tree, return _the length of the longest consecutive path in the tree_.

A consecutive path is a path where the values of the consecutive nodes in the path differ by one. This path can be either increasing or decreasing.

*   For example, `[1,2,3,4]` and `[4,3,2,1]` are both considered valid, but the path `[1,2,4,3]` is not valid.

On the other hand, the path can be in the child-Parent-child order, where not necessarily be parent-child order.

**Example 1:**

**Input:** root = \[1,2,3\]
**Output:** 2
**Explanation:** The longest consecutive path is \[1, 2\] or \[2, 1\].

**Example 2:**

**Input:** root = \[2,1,3\]
**Output:** 3
**Explanation:** The longest consecutive path is \[1, 2, 3\] or \[3, 2, 1\].

**Constraints:**

*   The number of nodes in the tree is in the range `[1, 3 * 104]`.
*   `-3 * 104 <= Node.val <= 3 * 104`
Student Attendance Record I

You are given a string `s` representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

*   `'A'`: Absent.
*   `'L'`: Late.
*   `'P'`: Present.

The student is eligible for an attendance award if they meet **both** of the following criteria:

*   The student was absent (`'A'`) for **strictly** fewer than 2 days **total**.
*   The student was **never** late (`'L'`) for 3 or more **consecutive** days.

Return `true` _if the student is eligible for an attendance award, or_ `false` _otherwise_.

**Example 1:**

**Input:** s =  "PPALLP "
**Output:** true
**Explanation:** The student has fewer than 2 absences and was never late 3 or more consecutive days.

**Example 2:**

**Input:** s =  "PPALLL "
**Output:** false
**Explanation:** The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.

**Constraints:**

*   `1 <= s.length <= 1000`
*   `s[i]` is either `'A'`, `'L'`, or `'P'`.
Student Attendance Record II

An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

*   `'A'`: Absent.
*   `'L'`: Late.
*   `'P'`: Present.

Any student is eligible for an attendance award if they meet **both** of the following criteria:

*   The student was absent (`'A'`) for **strictly** fewer than 2 days **total**.
*   The student was **never** late (`'L'`) for 3 or more **consecutive** days.

Given an integer `n`, return _the **number** of possible attendance records of length_ `n` _that make a student eligible for an attendance award. The answer may be very large, so return it **modulo**_ `109 + 7`.

**Example 1:**

**Input:** n = 2
**Output:** 8
**Explanation:** There are 8 records with length 2 that are eligible for an award:
 "PP ",  "AP ",  "PA ",  "LP ",  "PL ",  "AL ",  "LA ",  "LL "
Only  "AA " is not eligible because there are 2 absences (there need to be fewer than 2).

**Example 2:**

**Input:** n = 1
**Output:** 3

**Example 3:**

**Input:** n = 10101
**Output:** 183236316

**Constraints:**

*   `1 <= n <= 105`
Optimal Division

You are given an integer array `nums`. The adjacent integers in `nums` will perform the float division.

*   For example, for `nums = [2,3,4]`, we will evaluate the expression `"2/3/4 "`.

However, you can add any number of parenthesis at any position to change the priority of operations. You want to add these parentheses such the value of the expression after the evaluation is maximum.

Return _the corresponding expression that has the maximum value in string format_.

**Note:** your expression should not contain redundant parenthesis.

**Example 1:**

**Input:** nums = \[1000,100,10,2\]
**Output:**  "1000/(100/10/2) "
**Explanation:** 1000/(100/10/2) = 1000/((100/10)/2) = 200
However, the bold parenthesis in  "1000/(**(**100/10**)**/2) " are redundant since they do not influence the operation priority.
So you should return  "1000/(100/10/2) ".
Other cases:
1000/(100/10)/2 = 50
1000/(100/(10/2)) = 50
1000/100/10/2 = 0.5
1000/100/(10/2) = 2

**Example 2:**

**Input:** nums = \[2,3,4\]
**Output:**  "2/(3/4) "
**Explanation:** (2/(3/4)) = 8/3 = 2.667
It can be shown that after trying all possibilities, we cannot get an expression with evaluation greater than 2.667

**Constraints:**

*   `1 <= nums.length <= 10`
*   `2 <= nums[i] <= 1000`
*   There is only one optimal division for the given input.
Brick Wall

There is a rectangular brick wall in front of you with `n` rows of bricks. The `ith` row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.

Draw a vertical line from the top to the bottom and cross the least bricks. If your line goes through the edge of a brick, then the brick is not considered as crossed. You cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks.

Given the 2D array `wall` that contains the information about the wall, return _the minimum number of crossed bricks after drawing such a vertical line_.

**Example 1:**

**Input:** wall = \[\[1,2,2,1\],\[3,1,2\],\[1,3,2\],\[2,4\],\[3,1,2\],\[1,3,1,1\]\]
**Output:** 2

**Example 2:**

**Input:** wall = \[\[1\],\[1\],\[1\]\]
**Output:** 3

**Constraints:**

*   `n == wall.length`
*   `1 <= n <= 104`
*   `1 <= wall[i].length <= 104`
*   `1 <= sum(wall[i].length) <= 2 * 104`
*   `sum(wall[i])` is the same for each row `i`.
*   `1 <= wall[i][j] <= 231 - 1`
Split Concatenated Strings

You are given an array of strings `strs`. You could concatenate these strings together into a loop, where for each string, you could choose to reverse it or not. Among all the possible loops

Return _the lexicographically largest string after cutting the loop, which will make the looped string into a regular one_.

Specifically, to find the lexicographically largest string, you need to experience two phases:

1.  Concatenate all the strings into a loop, where you can reverse some strings or not and connect them in the same order as given.
2.  Cut and make one breakpoint in any place of the loop, which will make the looped string into a regular one starting from the character at the cutpoint.

And your job is to find the lexicographically largest one among all the possible regular strings.

**Example 1:**

**Input:** strs = \[ "abc ", "xyz "\]
**Output:**  "zyxcba "
**Explanation:** You can get the looped string  "-abcxyz- ",  "-abczyx- ",  "-cbaxyz- ",  "-cbazyx- ", where '-' represents the looped status. 
The answer string came from the fourth looped one, where you could cut from the middle character 'a' and get  "zyxcba ".

**Example 2:**

**Input:** strs = \[ "abc "\]
**Output:**  "cba "

**Constraints:**

*   `1 <= strs.length <= 1000`
*   `1 <= strs[i].length <= 1000`
*   `1 <= sum(strs[i].length) <= 1000`
*   `strs[i]` consists of lowercase English letters.
Next Greater Element III

Given a positive integer `n`, find _the smallest integer which has exactly the same digits existing in the integer_ `n` _and is greater in value than_ `n`. If no such positive integer exists, return `-1`.

**Note** that the returned integer should fit in **32-bit integer**, if there is a valid answer but it does not fit in **32-bit integer**, return `-1`.

**Example 1:**

**Input:** n = 12
**Output:** 21

**Example 2:**

**Input:** n = 21
**Output:** -1

**Constraints:**

*   `1 <= n <= 231 - 1`
Reverse Words in a String III

Given a string `s`, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

**Example 1:**

**Input:** s = "Let's take LeetCode contest"
**Output:** "s'teL ekat edoCteeL tsetnoc"

**Example 2:**

**Input:** s = "God Ding"
**Output:** "doG gniD"

**Constraints:**

*   `1 <= s.length <= 5 * 104`
*   `s` contains printable **ASCII** characters.
*   `s` does not contain any leading or trailing spaces.
*   There is **at least one** word in `s`.
*   All the words in `s` are separated by a single space.
Maximum Depth of N-ary Tree

Given a n-ary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

_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:** 3

**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:** 5

**Constraints:**

*   The total number of nodes is in the range `[0, 104]`.
*   The depth of the n-ary tree is less than or equal to `1000`.
Subarray Sum Equals K

Given an array of integers `nums` and an integer `k`, return _the total number of subarrays whose sum equals to_ `k`.

A subarray is a contiguous **non-empty** sequence of elements within an array.

**Example 1:**

**Input:** nums = \[1,1,1\], k = 2
**Output:** 2

**Example 2:**

**Input:** nums = \[1,2,3\], k = 3
**Output:** 2

**Constraints:**

*   `1 <= nums.length <= 2 * 104`
*   `-1000 <= nums[i] <= 1000`
*   `-107 <= k <= 107`
Array Partition

Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_.

**Example 1:**

**Input:** nums = \[1,4,3,2\]
**Output:** 4
**Explanation:** All possible pairings (ignoring the ordering of elements) are:
1. (1, 4), (2, 3) -> min(1, 4) + min(2, 3) = 1 + 2 = 3
2. (1, 3), (2, 4) -> min(1, 3) + min(2, 4) = 1 + 2 = 3
3. (1, 2), (3, 4) -> min(1, 2) + min(3, 4) = 1 + 3 = 4
So the maximum possible sum is 4.

**Example 2:**

**Input:** nums = \[6,2,6,5,1,2\]
**Output:** 9
**Explanation:** The optimal pairing is (2, 1), (2, 5), (6, 6). min(2, 1) + min(2, 5) + min(6, 6) = 1 + 2 + 6 = 9.

**Constraints:**

*   `1 <= n <= 104`
*   `nums.length == 2 * n`
*   `-104 <= nums[i] <= 104`
Longest Line of Consecutive One in Matrix

Given an `m x n` binary matrix `mat`, return _the length of the longest line of consecutive one in the matrix_.

The line could be horizontal, vertical, diagonal, or anti-diagonal.

**Example 1:**

**Input:** mat = \[\[0,1,1,0\],\[0,1,1,0\],\[0,0,0,1\]\]
**Output:** 3

**Example 2:**

**Input:** mat = \[\[1,1,1,1\],\[0,1,1,0\],\[0,0,0,1\]\]
**Output:** 4

**Constraints:**

*   `m == mat.length`
*   `n == mat[i].length`
*   `1 <= m, n <= 104`
*   `1 <= m * n <= 104`
*   `mat[i][j]` is either `0` or `1`.
Binary Tree Tilt

Given the `root` of a binary tree, return _the sum of every tree node's **tilt**._

The **tilt** of a tree node is the **absolute difference** between the sum of all left subtree node **values** and all right subtree node **values**. If a node does not have a left child, then the sum of the left subtree node **values** is treated as `0`. The rule is similar if the node does not have a right child.

**Example 1:**

**Input:** root = \[1,2,3\]
**Output:** 1
**Explanation:** 
Tilt of node 2 : |0-0| = 0 (no children)
Tilt of node 3 : |0-0| = 0 (no children)
Tilt of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3)
Sum of every tilt : 0 + 0 + 1 = 1

**Example 2:**

**Input:** root = \[4,2,9,3,5,null,7\]
**Output:** 15
**Explanation:** 
Tilt of node 3 : |0-0| = 0 (no children)
Tilt of node 5 : |0-0| = 0 (no children)
Tilt of node 7 : |0-0| = 0 (no children)
Tilt of node 2 : |3-5| = 2 (left subtree is just left child, so sum is 3; right subtree is just right child, so sum is 5)
Tilt of node 9 : |0-7| = 7 (no left child, so sum is 0; right subtree is just right child, so sum is 7)
Tilt of node 4 : |(3+5+2)-(9+7)| = |10-16| = 6 (left subtree values are 3, 5, and 2, which sums to 10; right subtree values are 9 and 7, which sums to 16)
Sum of every tilt : 0 + 0 + 0 + 2 + 7 + 6 = 15

**Example 3:**

**Input:** root = \[21,7,14,1,1,2,2,3,3\]
**Output:** 9

**Constraints:**

*   The number of nodes in the tree is in the range `[0, 104]`.
*   `-1000 <= Node.val <= 1000`
Find the Closest Palindrome

Given a string `n` representing an integer, return _the closest integer (not including itself), which is a palindrome_. If there is a tie, return _**the smaller one**_.

The closest is defined as the absolute difference minimized between two integers.

**Example 1:**

**Input:** n =  "123 "
**Output:**  "121 "

**Example 2:**

**Input:** n =  "1 "
**Output:**  "0 "
**Explanation:** 0 and 2 are the closest palindromes but we return the smallest which is 0.

**Constraints:**

*   `1 <= n.length <= 18`
*   `n` consists of only digits.
*   `n` does not have leading zeros.
*   `n` is representing an integer in the range `[1, 1018 - 1]`.
Array Nesting

You are given an integer array `nums` of length `n` where `nums` is a permutation of the numbers in the range `[0, n - 1]`.

You should build a set `s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }` subjected to the following rule:

*   The first element in `s[k]` starts with the selection of the element `nums[k]` of `index = k`.
*   The next element in `s[k]` should be `nums[nums[k]]`, and then `nums[nums[nums[k]]]`, and so on.
*   We stop adding right before a duplicate element occurs in `s[k]`.

Return _the longest length of a set_ `s[k]`.

**Example 1:**

**Input:** nums = \[5,4,0,3,1,6,2\]
**Output:** 4
**Explanation:** 
nums\[0\] = 5, nums\[1\] = 4, nums\[2\] = 0, nums\[3\] = 3, nums\[4\] = 1, nums\[5\] = 6, nums\[6\] = 2.
One of the longest sets s\[k\]:
s\[0\] = {nums\[0\], nums\[5\], nums\[6\], nums\[2\]} = {5, 6, 2, 0}

**Example 2:**

**Input:** nums = \[0,1,2\]
**Output:** 1

**Constraints:**

*   `1 <= nums.length <= 105`
*   `0 <= nums[i] < nums.length`
*   All the values of `nums` are **unique**.
Reshape the Matrix

In MATLAB, there is a handy function called `reshape` which can reshape an `m x n` matrix into a new one with a different size `r x c` keeping its original data.

You are given an `m x n` matrix `mat` and two integers `r` and `c` representing the number of rows and the number of columns of the wanted reshaped matrix.

The reshaped matrix should be filled with all the elements of the original matrix in the same row-traversing order as they were.

If the `reshape` operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

**Example 1:**

**Input:** mat = \[\[1,2\],\[3,4\]\], r = 1, c = 4
**Output:** \[\[1,2,3,4\]\]

**Example 2:**

**Input:** mat = \[\[1,2\],\[3,4\]\], r = 2, c = 4
**Output:** \[\[1,2\],\[3,4\]\]

**Constraints:**

*   `m == mat.length`
*   `n == mat[i].length`
*   `1 <= m, n <= 100`
*   `-1000 <= mat[i][j] <= 1000`
*   `1 <= r, c <= 300`
Permutation in String

Given two strings `s1` and `s2`, return `true` _if_ `s2` _contains a permutation of_ `s1`_, or_ `false` _otherwise_.

In other words, return `true` if one of `s1`'s permutations is the substring of `s2`.

**Example 1:**

**Input:** s1 =  "ab ", s2 =  "eidbaooo "
**Output:** true
**Explanation:** s2 contains one permutation of s1 ( "ba ").

**Example 2:**

**Input:** s1 =  "ab ", s2 =  "eidboaoo "
**Output:** false

**Constraints:**

*   `1 <= s1.length, s2.length <= 104`
*   `s1` and `s2` consist of lowercase English letters.
Subtree of Another Tree

Given the roots of two binary trees `root` and `subRoot`, return `true` if there is a subtree of `root` with the same structure and node values of `subRoot` and `false` otherwise.

A subtree of a binary tree `tree` is a tree that consists of a node in `tree` and all of this node's descendants. The tree `tree` could also be considered as a subtree of itself.

**Example 1:**

**Input:** root = \[3,4,5,1,2\], subRoot = \[4,1,2\]
**Output:** true

**Example 2:**

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

**Constraints:**

*   The number of nodes in the `root` tree is in the range `[1, 2000]`.
*   The number of nodes in the `subRoot` tree is in the range `[1, 1000]`.
*   `-104 <= root.val <= 104`
*   `-104 <= subRoot.val <= 104`
Squirrel Simulation

You are given two integers `height` and `width` representing a garden of size `height x width`. You are also given:

*   an array `tree` where `tree = [treer, treec]` is the position of the tree in the garden,
*   an array `squirrel` where `squirrel = [squirrelr, squirrelc]` is the position of the squirrel in the garden,
*   and an array `nuts` where `nuts[i] = [nutir, nutic]` is the position of the `ith` nut in the garden.

The squirrel can only take at most one nut at one time and can move in four directions: up, down, left, and right, to the adjacent cell.

Return _the **minimal distance** for the squirrel to collect all the nuts and put them under the tree one by one_.

The **distance** is the number of moves.

**Example 1:**

**Input:** height = 5, width = 7, tree = \[2,2\], squirrel = \[4,4\], nuts = \[\[3,0\], \[2,5\]\]
**Output:** 12
**Explanation:** The squirrel should go to the nut at \[2, 5\] first to achieve a minimal distance.

**Example 2:**

**Input:** height = 1, width = 3, tree = \[0,1\], squirrel = \[0,0\], nuts = \[\[0,2\]\]
**Output:** 3

**Constraints:**

*   `1 <= height, width <= 100`
*   `tree.length == 2`
*   `squirrel.length == 2`
*   `1 <= nuts.length <= 5000`
*   `nuts[i].length == 2`
*   `0 <= treer, squirrelr, nutir <= height`
*   `0 <= treec, squirrelc, nutic <= width`
Distribute Candies

Alice has `n` candies, where the `ith` candy is of type `candyType[i]`. Alice noticed that she started to gain weight, so she visited a doctor.

The doctor advised Alice to only eat `n / 2` of the candies she has (`n` is always even). Alice likes her candies very much, and she wants to eat the maximum number of different types of candies while still following the doctor's advice.

Given the integer array `candyType` of length `n`, return _the **maximum** number of different types of candies she can eat if she only eats_ `n / 2` _of them_.

**Example 1:**

**Input:** candyType = \[1,1,2,2,3,3\]
**Output:** 3
**Explanation:** Alice can only eat 6 / 2 = 3 candies. Since there are only 3 types, she can eat one of each type.

**Example 2:**

**Input:** candyType = \[1,1,2,3\]
**Output:** 2
**Explanation:** Alice can only eat 4 / 2 = 2 candies. Whether she eats types \[1,2\], \[1,3\], or \[2,3\], she still can only eat 2 different types.

**Example 3:**

**Input:** candyType = \[6,6,6,6\]
**Output:** 1
**Explanation:** Alice can only eat 4 / 2 = 2 candies. Even though she can eat 2 candies, she only has 1 type.

**Constraints:**

*   `n == candyType.length`
*   `2 <= n <= 104`
*   `n` is even.
*   `-105 <= candyType[i] <= 105`
Out of Boundary Paths

There is an `m x n` grid with a ball. The ball is initially at the position `[startRow, startColumn]`. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply **at most** `maxMove` moves to the ball.

Given the five integers `m`, `n`, `maxMove`, `startRow`, `startColumn`, return the number of paths to move the ball out of the grid boundary. Since the answer can be very large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0
**Output:** 6

**Example 2:**

**Input:** m = 1, n = 3, maxMove = 3, startRow = 0, startColumn = 1
**Output:** 12

**Constraints:**

*   `1 <= m, n <= 50`
*   `0 <= maxMove <= 50`
*   `0 <= startRow < m`
*   `0 <= startColumn < n`
Shortest Unsorted Continuous Subarray

Given an integer array `nums`, you need to find one **continuous subarray** that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order.

Return _the shortest such subarray and output its length_.

**Example 1:**

**Input:** nums = \[2,6,4,8,10,9,15\]
**Output:** 5
**Explanation:** You need to sort \[6, 4, 8, 10, 9\] in ascending order to make the whole array sorted in ascending order.

**Example 2:**

**Input:** nums = \[1,2,3,4\]
**Output:** 0

**Example 3:**

**Input:** nums = \[1\]
**Output:** 0

**Constraints:**

*   `1 <= nums.length <= 104`
*   `-105 <= nums[i] <= 105`

**Follow up:** Can you solve it in `O(n)` time complexity?
Kill Process

You have `n` processes forming a rooted tree structure. You are given two integer arrays `pid` and `ppid`, where `pid[i]` is the ID of the `ith` process and `ppid[i]` is the ID of the `ith` process's parent process.

Each process has only **one parent process** but may have multiple children processes. Only one process has `ppid[i] = 0`, which means this process has **no parent process** (the root of the tree).

When a process is **killed**, all of its children processes will also be killed.

Given an integer `kill` representing the ID of a process you want to kill, return _a list of the IDs of the processes that will be killed. You may return the answer in **any order**._

**Example 1:**

**Input:** pid = \[1,3,10,5\], ppid = \[3,0,5,3\], kill = 5
**Output:** \[5,10\]
**Explanation:** The processes colored in red are the processes that should be killed.

**Example 2:**

**Input:** pid = \[1\], ppid = \[0\], kill = 1
**Output:** \[1\]

**Constraints:**

*   `n == pid.length`
*   `n == ppid.length`
*   `1 <= n <= 5 * 104`
*   `1 <= pid[i] <= 5 * 104`
*   `0 <= ppid[i] <= 5 * 104`
*   Only one process has no parent.
*   All the values of `pid` are **unique**.
*   `kill` is **guaranteed** to be in `pid`.
Delete Operation for Two Strings

Given two strings `word1` and `word2`, return _the minimum number of **steps** required to make_ `word1` _and_ `word2` _the same_.

In one **step**, you can delete exactly one character in either string.

**Example 1:**

**Input:** word1 =  "sea ", word2 =  "eat "
**Output:** 2
**Explanation:** You need one step to make  "sea " to  "ea " and another step to make  "eat " to  "ea ".

**Example 2:**

**Input:** word1 =  "leetcode ", word2 =  "etco "
**Output:** 4

**Constraints:**

*   `1 <= word1.length, word2.length <= 500`
*   `word1` and `word2` consist of only lowercase English letters.