bowang0911/leetcode huggingface dataset:
Snakes and Ladders

You are given an `n x n` integer matrix `board` where the cells are labeled from `1` to `n2` in a [**Boustrophedon style**](https://en.wikipedia.org/wiki/Boustrophedon) starting from the bottom left of the board (i.e. `board[n - 1][0]`) and alternating direction each row.

You start on square `1` of the board. In each move, starting from square `curr`, do the following:

*   Choose a destination square `next` with a label in the range `[curr + 1, min(curr + 6, n2)]`.
    *   This choice simulates the result of a standard **6-sided die roll**: i.e., there are always at most 6 destinations, regardless of the size of the board.
*   If `next` has a snake or ladder, you **must** move to the destination of that snake or ladder. Otherwise, you move to `next`.
*   The game ends when you reach the square `n2`.

A board square on row `r` and column `c` has a snake or ladder if `board[r][c] != -1`. The destination of that snake or ladder is `board[r][c]`. Squares `1` and `n2` do not have a snake or ladder.

Note that you only take a snake or ladder at most once per move. If the destination to a snake or ladder is the start of another snake or ladder, you do **not** follow the subsequent snake or ladder.

*   For example, suppose the board is `[[-1,4],[-1,3]]`, and on the first move, your destination square is `2`. You follow the ladder to square `3`, but do **not** follow the subsequent ladder to `4`.

Return _the least number of moves required to reach the square_ `n2`_. If it is not possible to reach the square, return_ `-1`.

**Example 1:**

**Input:** board = \[\[-1,-1,-1,-1,-1,-1\],\[-1,-1,-1,-1,-1,-1\],\[-1,-1,-1,-1,-1,-1\],\[-1,35,-1,-1,13,-1\],\[-1,-1,-1,-1,-1,-1\],\[-1,15,-1,-1,-1,-1\]\]
**Output:** 4
**Explanation:** 
In the beginning, you start at square 1 (at row 5, column 0).
You decide to move to square 2 and must take the ladder to square 15.
You then decide to move to square 17 and must take the snake to square 13.
You then decide to move to square 14 and must take the ladder to square 35.
You then decide to move to square 36, ending the game.
This is the lowest possible number of moves to reach the last square, so return 4.

**Example 2:**

**Input:** board = \[\[-1,-1\],\[-1,3\]\]
**Output:** 1

**Constraints:**

*   `n == board.length == board[i].length`
*   `2 <= n <= 20`
*   `board[i][j]` is either `-1` or in the range `[1, n2]`.
*   The squares labeled `1` and `n2` do not have any ladders or snakes.
Smallest Range II

You are given an integer array `nums` and an integer `k`.

For each index `i` where `0 <= i < nums.length`, change `nums[i]` to be either `nums[i] + k` or `nums[i] - k`.

The **score** of `nums` is the difference between the maximum and minimum elements in `nums`.

Return _the minimum **score** of_ `nums` _after changing the values at each index_.

**Example 1:**

**Input:** nums = \[1\], k = 0
**Output:** 0
**Explanation:** The score is max(nums) - min(nums) = 1 - 1 = 0.

**Example 2:**

**Input:** nums = \[0,10\], k = 2
**Output:** 6
**Explanation:** Change nums to be \[2, 8\]. The score is max(nums) - min(nums) = 8 - 2 = 6.

**Example 3:**

**Input:** nums = \[1,3,6\], k = 3
**Output:** 3
**Explanation:** Change nums to be \[4, 6, 3\]. The score is max(nums) - min(nums) = 6 - 3 = 3.

**Constraints:**

*   `1 <= nums.length <= 104`
*   `0 <= nums[i] <= 104`
*   `0 <= k <= 104`
Online Election

You are given two integer arrays `persons` and `times`. In an election, the `ith` vote was cast for `persons[i]` at time `times[i]`.

For each query at a time `t`, find the person that was leading the election at time `t`. Votes cast at time `t` will count towards our query. In the case of a tie, the most recent vote (among tied candidates) wins.

Implement the `TopVotedCandidate` class:

*   `TopVotedCandidate(int[] persons, int[] times)` Initializes the object with the `persons` and `times` arrays.
*   `int q(int t)` Returns the number of the person that was leading the election at time `t` according to the mentioned rules.

**Example 1:**

**Input**
\[ "TopVotedCandidate ",  "q ",  "q ",  "q ",  "q ",  "q ",  "q "\]
\[\[\[0, 1, 1, 0, 0, 1, 0\], \[0, 5, 10, 15, 20, 25, 30\]\], \[3\], \[12\], \[25\], \[15\], \[24\], \[8\]\]
**Output**
\[null, 0, 1, 1, 0, 0, 1\]

**Explanation**
TopVotedCandidate topVotedCandidate = new TopVotedCandidate(\[0, 1, 1, 0, 0, 1, 0\], \[0, 5, 10, 15, 20, 25, 30\]);
topVotedCandidate.q(3); // return 0, At time 3, the votes are \[0\], and 0 is leading.
topVotedCandidate.q(12); // return 1, At time 12, the votes are \[0,1,1\], and 1 is leading.
topVotedCandidate.q(25); // return 1, At time 25, the votes are \[0,1,1,0,0,1\], and 1 is leading (as ties go to the most recent vote.)
topVotedCandidate.q(15); // return 0
topVotedCandidate.q(24); // return 0
topVotedCandidate.q(8); // return 1

**Constraints:**

*   `1 <= persons.length <= 5000`
*   `times.length == persons.length`
*   `0 <= persons[i] < persons.length`
*   `0 <= times[i] <= 109`
*   `times` is sorted in a strictly increasing order.
*   `times[0] <= t <= 109`
*   At most `104` calls will be made to `q`.
Sort an Array

Given an array of integers `nums`, sort the array in ascending order and return it.

You must solve the problem **without using any built-in** functions in `O(nlog(n))` time complexity and with the smallest space complexity possible.

**Example 1:**

**Input:** nums = \[5,2,3,1\]
**Output:** \[1,2,3,5\]
**Explanation:** After sorting the array, the positions of some numbers are not changed (for example, 2 and 3), while the positions of other numbers are changed (for example, 1 and 5).

**Example 2:**

**Input:** nums = \[5,1,1,2,0,0\]
**Output:** \[0,0,1,1,2,5\]
**Explanation:** Note that the values of nums are not necessairly unique.

**Constraints:**

*   `1 <= nums.length <= 5 * 104`
*   `-5 * 104 <= nums[i] <= 5 * 104`
Cat and Mouse

A game on an **undirected** graph is played by two players, Mouse and Cat, who alternate turns.

The graph is given as follows: `graph[a]` is a list of all nodes `b` such that `ab` is an edge of the graph.

The mouse starts at node `1` and goes first, the cat starts at node `2` and goes second, and there is a hole at node `0`.

During each player's turn, they **must** travel along one edge of the graph that meets where they are. For example, if the Mouse is at node 1, it **must** travel to any node in `graph[1]`.

Additionally, it is not allowed for the Cat to travel to the Hole (node 0.)

Then, the game can end in three ways:

*   If ever the Cat occupies the same node as the Mouse, the Cat wins.
*   If ever the Mouse reaches the Hole, the Mouse wins.
*   If ever a position is repeated (i.e., the players are in the same position as a previous turn, and it is the same player's turn to move), the game is a draw.

Given a `graph`, and assuming both players play optimally, return

*   `1` if the mouse wins the game,
*   `2` if the cat wins the game, or
*   `0` if the game is a draw.

**Example 1:**

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

**Example 2:**

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

**Constraints:**

*   `3 <= graph.length <= 50`
*   `1 <= graph[i].length < graph.length`
*   `0 <= graph[i][j] < graph.length`
*   `graph[i][j] != i`
*   `graph[i]` is unique.
*   The mouse and the cat can always move.
X of a Kind in a Deck of Cards

You are given an integer array `deck` where `deck[i]` represents the number written on the `ith` card.

Partition the cards into **one or more groups** such that:

*   Each group has **exactly** `x` cards where `x > 1`, and
*   All the cards in one group have the same integer written on them.

Return `true` _if such partition is possible, or_ `false` _otherwise_.

**Example 1:**

**Input:** deck = \[1,2,3,4,4,3,2,1\]
**Output:** true
**Explanation**: Possible partition \[1,1\],\[2,2\],\[3,3\],\[4,4\].

**Example 2:**

**Input:** deck = \[1,1,1,2,2,2,3,3\]
**Output:** false
**Explanation**: No possible partition.

**Constraints:**

*   `1 <= deck.length <= 104`
*   `0 <= deck[i] < 104`
Partition Array into Disjoint Intervals

Given an integer array `nums`, partition it into two (contiguous) subarrays `left` and `right` so that:

*   Every element in `left` is less than or equal to every element in `right`.
*   `left` and `right` are non-empty.
*   `left` has the smallest possible size.

Return _the length of_ `left` _after such a partitioning_.

Test cases are generated such that partitioning exists.

**Example 1:**

**Input:** nums = \[5,0,3,8,6\]
**Output:** 3
**Explanation:** left = \[5,0,3\], right = \[8,6\]

**Example 2:**

**Input:** nums = \[1,1,1,0,6,12\]
**Output:** 4
**Explanation:** left = \[1,1,1,0\], right = \[6,12\]

**Constraints:**

*   `2 <= nums.length <= 105`
*   `0 <= nums[i] <= 106`
*   There is at least one valid answer for the given input.
Word Subsets

You are given two string arrays `words1` and `words2`.

A string `b` is a **subset** of string `a` if every letter in `b` occurs in `a` including multiplicity.

*   For example, `"wrr "` is a subset of `"warrior "` but is not a subset of `"world "`.

A string `a` from `words1` is **universal** if for every string `b` in `words2`, `b` is a subset of `a`.

Return an array of all the **universal** strings in `words1`. You may return the answer in **any order**.

**Example 1:**

**Input:** words1 = \[ "amazon ", "apple ", "facebook ", "google ", "leetcode "\], words2 = \[ "e ", "o "\]
**Output:** \[ "facebook ", "google ", "leetcode "\]

**Example 2:**

**Input:** words1 = \[ "amazon ", "apple ", "facebook ", "google ", "leetcode "\], words2 = \[ "l ", "e "\]
**Output:** \[ "apple ", "google ", "leetcode "\]

**Constraints:**

*   `1 <= words1.length, words2.length <= 104`
*   `1 <= words1[i].length, words2[i].length <= 10`
*   `words1[i]` and `words2[i]` consist only of lowercase English letters.
*   All the strings of `words1` are **unique**.
Reverse Only Letters

Given a string `s`, reverse the string according to the following rules:

*   All the characters that are not English letters remain in the same position.
*   All the English letters (lowercase or uppercase) should be reversed.

Return `s` _after reversing it_.

**Example 1:**

**Input:** s = "ab-cd"
**Output:** "dc-ba"

**Example 2:**

**Input:** s = "a-bC-dEf-ghIj"
**Output:** "j-Ih-gfE-dCba"

**Example 3:**

**Input:** s = "Test1ng-Leet=code-Q!"
**Output:** "Qedo1ct-eeLg=ntse-T!"

**Constraints:**

*   `1 <= s.length <= 100`
*   `s` consists of characters with ASCII values in the range `[33, 122]`.
*   `s` does not contain `'\ "'` or `'\\'`.
Maximum Sum Circular Subarray

Given a **circular integer array** `nums` of length `n`, return _the maximum possible sum of a non-empty **subarray** of_ `nums`.

A **circular array** means the end of the array connects to the beginning of the array. Formally, the next element of `nums[i]` is `nums[(i + 1) % n]` and the previous element of `nums[i]` is `nums[(i - 1 + n) % n]`.

A **subarray** may only include each element of the fixed buffer `nums` at most once. Formally, for a subarray `nums[i], nums[i + 1], ..., nums[j]`, there does not exist `i <= k1`, `k2 <= j` with `k1 % n == k2 % n`.

**Example 1:**

**Input:** nums = \[1,-2,3,-2\]
**Output:** 3
**Explanation:** Subarray \[3\] has maximum sum 3.

**Example 2:**

**Input:** nums = \[5,-3,5\]
**Output:** 10
**Explanation:** Subarray \[5,5\] has maximum sum 5 + 5 = 10.

**Example 3:**

**Input:** nums = \[-3,-2,-3\]
**Output:** -2
**Explanation:** Subarray \[-2\] has maximum sum -2.

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 3 * 104`
*   `-3 * 104 <= nums[i] <= 3 * 104`
Complete Binary Tree Inserter

A **complete binary tree** is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

Design an algorithm to insert a new node to a complete binary tree keeping it complete after the insertion.

Implement the `CBTInserter` class:

*   `CBTInserter(TreeNode root)` Initializes the data structure with the `root` of the complete binary tree.
*   `int insert(int v)` Inserts a `TreeNode` into the tree with value `Node.val == val` so that the tree remains complete, and returns the value of the parent of the inserted `TreeNode`.
*   `TreeNode get_root()` Returns the root node of the tree.

**Example 1:**

**Input**
\[ "CBTInserter ",  "insert ",  "insert ",  "get\_root "\]
\[\[\[1, 2\]\], \[3\], \[4\], \[\]\]
**Output**
\[null, 1, 2, \[1, 2, 3, 4\]\]

**Explanation**
CBTInserter cBTInserter = new CBTInserter(\[1, 2\]);
cBTInserter.insert(3);  // return 1
cBTInserter.insert(4);  // return 2
cBTInserter.get\_root(); // return \[1, 2, 3, 4\]

**Constraints:**

*   The number of nodes in the tree will be in the range `[1, 1000]`.
*   `0 <= Node.val <= 5000`
*   `root` is a complete binary tree.
*   `0 <= val <= 5000`
*   At most `104` calls will be made to `insert` and `get_root`.
Number of Music Playlists

Your music player contains `n` different songs. You want to listen to `goal` songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:

*   Every song is played **at least once**.
*   A song can only be played again only if `k` other songs have been played.

Given `n`, `goal`, and `k`, return _the number of possible playlists that you can create_. Since the answer can be very large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** n = 3, goal = 3, k = 1
**Output:** 6
**Explanation:** There are 6 possible playlists: \[1, 2, 3\], \[1, 3, 2\], \[2, 1, 3\], \[2, 3, 1\], \[3, 1, 2\], and \[3, 2, 1\].

**Example 2:**

**Input:** n = 2, goal = 3, k = 0
**Output:** 6
**Explanation:** There are 6 possible playlists: \[1, 1, 2\], \[1, 2, 1\], \[2, 1, 1\], \[2, 2, 1\], \[2, 1, 2\], and \[1, 2, 2\].

**Example 3:**

**Input:** n = 2, goal = 3, k = 1
**Output:** 2
**Explanation:** There are 2 possible playlists: \[1, 2, 1\] and \[2, 1, 2\].

**Constraints:**

*   `0 <= k < n <= goal <= 100`
Minimum Add to Make Parentheses Valid

A parentheses string is valid if and only if:

*   It is the empty string,
*   It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or
*   It can be written as `(A)`, where `A` is a valid string.

You are given a parentheses string `s`. In one move, you can insert a parenthesis at any position of the string.

*   For example, if `s = "())) "`, you can insert an opening parenthesis to be `"(**(**))) "` or a closing parenthesis to be `"())**)**) "`.

Return _the minimum number of moves required to make_ `s` _valid_.

**Example 1:**

**Input:** s =  "()) "
**Output:** 1

**Example 2:**

**Input:** s =  "((( "
**Output:** 3

**Constraints:**

*   `1 <= s.length <= 1000`
*   `s[i]` is either `'('` or `')'`.
Sort Array By Parity II

Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**.

Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**.

Return _any answer array that satisfies this condition_.

**Example 1:**

**Input:** nums = \[4,2,5,7\]
**Output:** \[4,5,2,7\]
**Explanation:** \[4,7,2,5\], \[2,5,4,7\], \[2,7,4,5\] would also have been accepted.

**Example 2:**

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

**Constraints:**

*   `2 <= nums.length <= 2 * 104`
*   `nums.length` is even.
*   Half of the integers in `nums` are even.
*   `0 <= nums[i] <= 1000`

**Follow Up:** Could you solve it in-place?
3Sum With Multiplicity

Given an integer array `arr`, and an integer `target`, return the number of tuples `i, j, k` such that `i < j < k` and `arr[i] + arr[j] + arr[k] == target`.

As the answer can be very large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** arr = \[1,1,2,2,3,3,4,4,5,5\], target = 8
**Output:** 20
**Explanation:** 
Enumerating by the values (arr\[i\], arr\[j\], arr\[k\]):
(1, 2, 5) occurs 8 times;
(1, 3, 4) occurs 8 times;
(2, 2, 4) occurs 2 times;
(2, 3, 3) occurs 2 times.

**Example 2:**

**Input:** arr = \[1,1,2,2,2,2\], target = 5
**Output:** 12
**Explanation:** 
arr\[i\] = 1, arr\[j\] = arr\[k\] = 2 occurs 12 times:
We choose one 1 from \[1,1\] in 2 ways,
and two 2s from \[2,2,2,2\] in 6 ways.

**Example 3:**

**Input:** arr = \[2,1,3\], target = 6
**Output:** 1
**Explanation:** (1, 2, 3) occured one time in the array so we return 1.

**Constraints:**

*   `3 <= arr.length <= 3000`
*   `0 <= arr[i] <= 100`
*   `0 <= target <= 300`
Minimize Malware Spread

You are given a network of `n` nodes represented as an `n x n` adjacency matrix `graph`, where the `ith` node is directly connected to the `jth` node if `graph[i][j] == 1`.

Some nodes `initial` are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

Suppose `M(initial)` is the final number of nodes infected with malware in the entire network after the spread of malware stops. We will remove **exactly one node** from `initial`.

Return the node that, if removed, would minimize `M(initial)`. If multiple nodes could be removed to minimize `M(initial)`, return such a node with **the smallest index**.

Note that if a node was removed from the `initial` list of infected nodes, it might still be infected later due to the malware spread.

**Example 1:**

**Input:** graph = \[\[1,1,0\],\[1,1,0\],\[0,0,1\]\], initial = \[0,1\]
**Output:** 0

**Example 2:**

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

**Example 3:**

**Input:** graph = \[\[1,1,1\],\[1,1,1\],\[1,1,1\]\], initial = \[1,2\]
**Output:** 1

**Constraints:**

*   `n == graph.length`
*   `n == graph[i].length`
*   `2 <= n <= 300`
*   `graph[i][j]` is `0` or `1`.
*   `graph[i][j] == graph[j][i]`
*   `graph[i][i] == 1`
*   `1 <= initial.length <= n`
*   `0 <= initial[i] <= n - 1`
*   All the integers in `initial` are **unique**.
Long Pressed Name

Your friend is typing his `name` into a keyboard. Sometimes, when typing a character `c`, the key might get _long pressed_, and the character will be typed 1 or more times.

You examine the `typed` characters of the keyboard. Return `True` if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

**Example 1:**

**Input:** name =  "alex ", typed =  "aaleex "
**Output:** true
**Explanation:** 'a' and 'e' in 'alex' were long pressed.

**Example 2:**

**Input:** name =  "saeed ", typed =  "ssaaedd "
**Output:** false
**Explanation:** 'e' must have been pressed twice, but it was not in the typed output.

**Constraints:**

*   `1 <= name.length, typed.length <= 1000`
*   `name` and `typed` consist of only lowercase English letters.
Flip String to Monotone Increasing

A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none).

You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`.

Return _the minimum number of flips to make_ `s` _monotone increasing_.

**Example 1:**

**Input:** s =  "00110 "
**Output:** 1
**Explanation:** We flip the last digit to get 00111.

**Example 2:**

**Input:** s =  "010110 "
**Output:** 2
**Explanation:** We flip to get 011111, or alternatively 000111.

**Example 3:**

**Input:** s =  "00011000 "
**Output:** 2
**Explanation:** We flip to get 00000000.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s[i]` is either `'0'` or `'1'`.
Three Equal Parts

You are given an array `arr` which consists of only zeros and ones, divide the array into **three non-empty parts** such that all of these parts represent the same binary value.

If it is possible, return any `[i, j]` with `i + 1 < j`, such that:

*   `arr[0], arr[1], ..., arr[i]` is the first part,
*   `arr[i + 1], arr[i + 2], ..., arr[j - 1]` is the second part, and
*   `arr[j], arr[j + 1], ..., arr[arr.length - 1]` is the third part.
*   All three parts have equal binary values.

If it is not possible, return `[-1, -1]`.

Note that the entire part is used when considering what binary value it represents. For example, `[1,1,0]` represents `6` in decimal, not `3`. Also, leading zeros **are allowed**, so `[0,1,1]` and `[1,1]` represent the same value.

**Example 1:**

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

**Example 2:**

**Input:** arr = \[1,1,0,1,1\]
**Output:** \[-1,-1\]

**Example 3:**

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

**Constraints:**

*   `3 <= arr.length <= 3 * 104`
*   `arr[i]` is `0` or `1`
Minimize Malware Spread II

You are given a network of `n` nodes represented as an `n x n` adjacency matrix `graph`, where the `ith` node is directly connected to the `jth` node if `graph[i][j] == 1`.

Some nodes `initial` are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

Suppose `M(initial)` is the final number of nodes infected with malware in the entire network after the spread of malware stops.

We will remove **exactly one node** from `initial`, **completely removing it and any connections from this node to any other node**.

Return the node that, if removed, would minimize `M(initial)`. If multiple nodes could be removed to minimize `M(initial)`, return such a node with **the smallest index**.

**Example 1:**

**Input:** graph = \[\[1,1,0\],\[1,1,0\],\[0,0,1\]\], initial = \[0,1\]
**Output:** 0

**Example 2:**

**Input:** graph = \[\[1,1,0\],\[1,1,1\],\[0,1,1\]\], initial = \[0,1\]
**Output:** 1

**Example 3:**

**Input:** graph = \[\[1,1,0,0\],\[1,1,1,0\],\[0,1,1,1\],\[0,0,1,1\]\], initial = \[0,1\]
**Output:** 1

**Constraints:**

*   `n == graph.length`
*   `n == graph[i].length`
*   `2 <= n <= 300`
*   `graph[i][j]` is `0` or `1`.
*   `graph[i][j] == graph[j][i]`
*   `graph[i][i] == 1`
*   `1 <= initial.length < n`
*   `0 <= initial[i] <= n - 1`
*   All the integers in `initial` are **unique**.
Unique Email Addresses

Every **valid email** consists of a **local name** and a **domain name**, separated by the `'@'` sign. Besides lowercase letters, the email may contain one or more `'.'` or `'+'`.

*   For example, in `"alice@leetcode.com "`, `"alice "` is the **local name**, and `"leetcode.com "` is the **domain name**.

If you add periods `'.'` between some characters in the **local name** part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule **does not apply** to **domain names**.

*   For example, `"alice.z@leetcode.com "` and `"alicez@leetcode.com "` forward to the same email address.

If you add a plus `'+'` in the **local name**, everything after the first plus sign **will be ignored**. This allows certain emails to be filtered. Note that this rule **does not apply** to **domain names**.

*   For example, `"m.y+name@email.com "` will be forwarded to `"my@email.com "`.

It is possible to use both of these rules at the same time.

Given an array of strings `emails` where we send one email to each `emails[i]`, return _the number of different addresses that actually receive mails_.

**Example 1:**

**Input:** emails = \[ "test.email+alex@leetcode.com ", "test.e.mail+bob.cathy@leetcode.com ", "testemail+david@lee.tcode.com "\]
**Output:** 2
**Explanation:**  "testemail@leetcode.com " and  "testemail@lee.tcode.com " actually receive mails.

**Example 2:**

**Input:** emails = \[ "a@leetcode.com ", "b@leetcode.com ", "c@leetcode.com "\]
**Output:** 3

**Constraints:**

*   `1 <= emails.length <= 100`
*   `1 <= emails[i].length <= 100`
*   `emails[i]` consist of lowercase English letters, `'+'`, `'.'` and `'@'`.
*   Each `emails[i]` contains exactly one `'@'` character.
*   All local and domain names are non-empty.
*   Local names do not start with a `'+'` character.
*   Domain names end with the `".com "` suffix.