bowang0911/leetcode huggingface dataset:
Maximum Performance of a Team

You are given two integers `n` and `k` and two integer arrays `speed` and `efficiency` both of length `n`. There are `n` engineers numbered from `1` to `n`. `speed[i]` and `efficiency[i]` represent the speed and efficiency of the `ith` engineer respectively.

Choose **at most** `k` different engineers out of the `n` engineers to form a team with the maximum **performance**.

The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers.

Return _the maximum performance of this team_. Since the answer can be a huge number, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** n = 6, speed = \[2,10,3,1,5,8\], efficiency = \[5,4,3,9,7,2\], k = 2
**Output:** 60
**Explanation:** 
We have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) \* min(4, 7) = 60.

**Example 2:**

**Input:** n = 6, speed = \[2,10,3,1,5,8\], efficiency = \[5,4,3,9,7,2\], k = 3
**Output:** 68
**Explanation:**
This is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) \* min(5, 4, 7) = 68.

**Example 3:**

**Input:** n = 6, speed = \[2,10,3,1,5,8\], efficiency = \[5,4,3,9,7,2\], k = 4
**Output:** 72

**Constraints:**

*   `1 <= k <= n <= 105`
*   `speed.length == n`
*   `efficiency.length == n`
*   `1 <= speed[i] <= 105`
*   `1 <= efficiency[i] <= 108`
Find the Distance Value Between Two Arrays

Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_.

The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` where `|arr1[i]-arr2[j]| <= d`.

**Example 1:**

**Input:** arr1 = \[4,5,8\], arr2 = \[10,9,1,8\], d = 2
**Output:** 2
**Explanation:** 
For arr1\[0\]=4 we have: 
|4-10|=6 > d=2 
|4-9|=5 > d=2 
|4-1|=3 > d=2 
|4-8|=4 > d=2 
For arr1\[1\]=5 we have: 
|5-10|=5 > d=2 
|5-9|=4 > d=2 
|5-1|=4 > d=2 
|5-8|=3 > d=2
For arr1\[2\]=8 we have:
**|8-10|=2 <= d=2**
**|8-9|=1 <= d=2**
|8-1|=7 > d=2
**|8-8|=0 <= d=2**

**Example 2:**

**Input:** arr1 = \[1,4,2,3\], arr2 = \[-4,-3,6,10,20,30\], d = 3
**Output:** 2

**Example 3:**

**Input:** arr1 = \[2,1,100,3\], arr2 = \[-5,-2,10,-3,7\], d = 6
**Output:** 1

**Constraints:**

*   `1 <= arr1.length, arr2.length <= 500`
*   `-1000 <= arr1[i], arr2[j] <= 1000`
*   `0 <= d <= 100`
Cinema Seat Allocation

A cinema has `n` rows of seats, numbered from 1 to `n` and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.

Given the array `reservedSeats` containing the numbers of seats already reserved, for example, `reservedSeats[i] = [3,8]` means the seat located in row **3** and labelled with **8** is already reserved.

_Return the maximum number of four-person groups you can assign on the cinema seats._ A four-person group occupies four adjacent seats **in one single row**. Seats across an aisle (such as \[3,3\] and \[3,4\]) are not considered to be adjacent, but there is an exceptional case on which an aisle split a four-person group, in that case, the aisle split a four-person group in the middle, which means to have two people on each side.

**Example 1:**

**Input:** n = 3, reservedSeats = \[\[1,2\],\[1,3\],\[1,8\],\[2,6\],\[3,1\],\[3,10\]\]
**Output:** 4
**Explanation:** The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.

**Example 2:**

**Input:** n = 2, reservedSeats = \[\[2,1\],\[1,8\],\[2,6\]\]
**Output:** 2

**Example 3:**

**Input:** n = 4, reservedSeats = \[\[4,3\],\[1,4\],\[4,6\],\[1,7\]\]
**Output:** 4

**Constraints:**

*   `1 <= n <= 10^9`
*   `1 <= reservedSeats.length <= min(10*n, 10^4)`
*   `reservedSeats[i].length == 2`
*   `1 <= reservedSeats[i][0] <= n`
*   `1 <= reservedSeats[i][1] <= 10`
*   All `reservedSeats[i]` are distinct.
Pizza With 3n Slices

There is a pizza with `3n` slices of varying size, you and your friends will take slices of pizza as follows:

*   You will pick **any** pizza slice.
*   Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
*   Your friend Bob will pick the next slice in the clockwise direction of your pick.
*   Repeat until there are no more slices of pizzas.

Given an integer array `slices` that represent the sizes of the pizza slices in a clockwise direction, return _the maximum possible sum of slice sizes that you can pick_.

**Example 1:**

**Input:** slices = \[1,2,3,4,5,6\]
**Output:** 10
**Explanation:** Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.

**Example 2:**

**Input:** slices = \[8,9,8,6,1,1\]
**Output:** 16
**Explanation:** Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.

**Constraints:**

*   `3 * n == slices.length`
*   `1 <= slices.length <= 500`
*   `1 <= slices[i] <= 1000`
Four Divisors

Given an integer array `nums`, return _the sum of divisors of the integers in that array that have exactly four divisors_. If there is no such integer in the array, return `0`.

**Example 1:**

**Input:** nums = \[21,4,7\]
**Output:** 32
**Explanation:** 
21 has 4 divisors: 1, 3, 7, 21
4 has 3 divisors: 1, 2, 4
7 has 2 divisors: 1, 7
The answer is the sum of divisors of 21 only.

**Example 2:**

**Input:** nums = \[21,21\]
**Output:** 64

**Example 3:**

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

**Constraints:**

*   `1 <= nums.length <= 104`
*   `1 <= nums[i] <= 105`
Check if There is a Valid Path in a Grid

You are given an `m x n` `grid`. Each cell of `grid` represents a street. The street of `grid[i][j]` can be:

*   `1` which means a street connecting the left cell and the right cell.
*   `2` which means a street connecting the upper cell and the lower cell.
*   `3` which means a street connecting the left cell and the lower cell.
*   `4` which means a street connecting the right cell and the lower cell.
*   `5` which means a street connecting the left cell and the upper cell.
*   `6` which means a street connecting the right cell and the upper cell.

You will initially start at the street of the upper-left cell `(0, 0)`. A valid path in the grid is a path that starts from the upper left cell `(0, 0)` and ends at the bottom-right cell `(m - 1, n - 1)`. **The path should only follow the streets**.

**Notice** that you are **not allowed** to change any street.

Return `true` _if there is a valid path in the grid or_ `false` _otherwise_.

**Example 1:**

**Input:** grid = \[\[2,4,3\],\[6,5,2\]\]
**Output:** true
**Explanation:** As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).

**Example 2:**

**Input:** grid = \[\[1,2,1\],\[1,2,1\]\]
**Output:** false
**Explanation:** As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)

**Example 3:**

**Input:** grid = \[\[1,1,2\]\]
**Output:** false
**Explanation:** You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 300`
*   `1 <= grid[i][j] <= 6`
Find Lucky Integer in an Array

Given an array of integers `arr`, a **lucky integer** is an integer that has a frequency in the array equal to its value.

Return _the largest **lucky integer** in the array_. If there is no **lucky integer** return `-1`.

**Example 1:**

**Input:** arr = \[2,2,3,4\]
**Output:** 2
**Explanation:** The only lucky number in the array is 2 because frequency\[2\] == 2.

**Example 2:**

**Input:** arr = \[1,2,2,3,3,3\]
**Output:** 3
**Explanation:** 1, 2 and 3 are all lucky numbers, return the largest of them.

**Example 3:**

**Input:** arr = \[2,2,2,3,3\]
**Output:** -1
**Explanation:** There are no lucky numbers in the array.

**Constraints:**

*   `1 <= arr.length <= 500`
*   `1 <= arr[i] <= 500`
Count Number of Teams

There are `n` soldiers standing in a line. Each soldier is assigned a **unique** `rating` value.

You have to form a team of 3 soldiers amongst them under the following rules:

*   Choose 3 soldiers with index (`i`, `j`, `k`) with rating (`rating[i]`, `rating[j]`, `rating[k]`).
*   A team is valid if: (`rating[i] < rating[j] < rating[k]`) or (`rating[i] > rating[j] > rating[k]`) where (`0 <= i < j < k < n`).

Return the number of teams you can form given the conditions. (soldiers can be part of multiple teams).

**Example 1:**

**Input:** rating = \[2,5,3,4,1\]
**Output:** 3
**Explanation:** We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1). 

**Example 2:**

**Input:** rating = \[2,1,3\]
**Output:** 0
**Explanation:** We can't form any team given the conditions.

**Example 3:**

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

**Constraints:**

*   `n == rating.length`
*   `3 <= n <= 1000`
*   `1 <= rating[i] <= 105`
*   All the integers in `rating` are **unique**.

In one second, you can either: - Move vertically by one unit, - Move horizontally by one unit, or - Move diagonally sqrt(2) units (in other words, move one unit vertically then one unit horizontally in one second). You have to visit the points in the same order as they appear in the array. You are allowed to pass through points, but they do not count as visited unless you stop on them.
Find All Good Strings

Given the strings `s1` and `s2` of size `n` and the string `evil`, return _the number of **good** strings_.

A **good** string has size `n`, it is alphabetically greater than or equal to `s1`, it is alphabetically smaller than or equal to `s2`, and it does not contain the string `evil` as a substring. Since the answer can be a huge number, return this **modulo** `109 + 7`.

**Example 1:**

**Input:** n = 2, s1 =  "aa ", s2 =  "da ", evil =  "b "
**Output:** 51 
**Explanation:** There are 25 good strings starting with 'a':  "aa ", "ac ", "ad ",..., "az ". Then there are 25 good strings starting with 'c':  "ca ", "cc ", "cd ",..., "cz " and finally there is one good string starting with 'd':  "da ". 

**Example 2:**

**Input:** n = 8, s1 =  "leetcode ", s2 =  "leetgoes ", evil =  "leet "
**Output:** 0 
**Explanation:** All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix  "leet ", therefore, there is not any good string.

**Example 3:**

**Input:** n = 2, s1 =  "gx ", s2 =  "gz ", evil =  "x "
**Output:** 2

**Constraints:**

*   `s1.length == n`
*   `s2.length == n`
*   `s1 <= s2`
*   `1 <= n <= 500`
*   `1 <= evil.length <= 50`
*   All strings consist of lowercase English letters.
Count Largest Group

You are given an integer `n`.

Each number from `1` to `n` is grouped according to the sum of its digits.

Return _the number of groups that have the largest size_.

**Example 1:**

**Input:** n = 13
**Output:** 4
**Explanation:** There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:
\[1,10\], \[2,11\], \[3,12\], \[4,13\], \[5\], \[6\], \[7\], \[8\], \[9\].
There are 4 groups with largest size.

**Example 2:**

**Input:** n = 2
**Output:** 2
**Explanation:** There are 2 groups \[1\], \[2\] of size 1.

**Constraints:**

*   `1 <= n <= 104`
Construct K Palindrome Strings

Given a string `s` and an integer `k`, return `true` _if you can use all the characters in_ `s` _to construct_ `k` _palindrome strings or_ `false` _otherwise_.

**Example 1:**

**Input:** s =  "annabelle ", k = 2
**Output:** true
**Explanation:** You can construct two palindromes using all characters in s.
Some possible constructions  "anna " +  "elble ",  "anbna " +  "elle ",  "anellena " +  "b "

**Example 2:**

**Input:** s =  "leetcode ", k = 3
**Output:** false
**Explanation:** It is impossible to construct 3 palindromes using all the characters of s.

**Example 3:**

**Input:** s =  "true ", k = 4
**Output:** true
**Explanation:** The only possible solution is to put each character in a separate string.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s` consists of lowercase English letters.
*   `1 <= k <= 105`
Circle and Rectangle Overlapping

You are given a circle represented as `(radius, xCenter, yCenter)` and an axis-aligned rectangle represented as `(x1, y1, x2, y2)`, where `(x1, y1)` are the coordinates of the bottom-left corner, and `(x2, y2)` are the coordinates of the top-right corner of the rectangle.

Return `true` _if the circle and rectangle are overlapped otherwise return_ `false`. In other words, check if there is **any** point `(xi, yi)` that belongs to the circle and the rectangle at the same time.

**Example 1:**

**Input:** radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
**Output:** true
**Explanation:** Circle and rectangle share the point (1,0).

**Example 2:**

**Input:** radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
**Output:** false

**Example 3:**

**Input:** radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
**Output:** true

**Constraints:**

*   `1 <= radius <= 2000`
*   `-104 <= xCenter, yCenter <= 104`
*   `-104 <= x1 < x2 <= 104`
*   `-104 <= y1 < y2 <= 104`
Reducing Dishes

A chef has collected data on the `satisfaction` level of his `n` dishes. Chef can cook any dish in 1 unit of time.

**Like-time coefficient** of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. `time[i] * satisfaction[i]`.

Return _the maximum sum of **like-time coefficient** that the chef can obtain after dishes preparation_.

Dishes can be prepared in **any** order and the chef can discard some dishes to get this maximum value.

**Example 1:**

**Input:** satisfaction = \[-1,-8,0,5,-9\]
**Output:** 14
**Explanation:** After Removing the second and last dish, the maximum total **like-time coefficient** will be equal to (-1\*1 + 0\*2 + 5\*3 = 14).
Each dish is prepared in one unit of time.

**Example 2:**

**Input:** satisfaction = \[4,3,2\]
**Output:** 20
**Explanation:** Dishes can be prepared in any order, (2\*1 + 3\*2 + 4\*3 = 20)

**Example 3:**

**Input:** satisfaction = \[-1,-4,-5\]
**Output:** 0
**Explanation:** People do not like the dishes. No dish is prepared.

**Constraints:**

*   `n == satisfaction.length`
*   `1 <= n <= 500`
*   `-1000 <= satisfaction[i] <= 1000`
Minimum Subsequence in Non-Increasing Order

Given the array `nums`, obtain a subsequence of the array whose sum of elements is **strictly greater** than the sum of the non included elements in such subsequence.

If there are multiple solutions, return the subsequence with **minimum size** and if there still exist multiple solutions, return the subsequence with the **maximum total sum** of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.

Note that the solution with the given constraints is guaranteed to be **unique**. Also return the answer sorted in **non-increasing** order.

**Example 1:**

**Input:** nums = \[4,3,10,9,8\]
**Output:** \[10,9\] 
**Explanation:** The subsequences \[10,9\] and \[10,8\] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence \[10,9\] has the maximum total sum of its elements. 

**Example 2:**

**Input:** nums = \[4,4,7,6,7\]
**Output:** \[7,7,6\] 
**Explanation:** The subsequence \[7,7\] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence \[7,6,7\] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-decreasing order.  

**Constraints:**

*   `1 <= nums.length <= 500`
*   `1 <= nums[i] <= 100`
Number of Steps to Reduce a Number in Binary Representation to One

Given the binary representation of an integer as a string `s`, return _the number of steps to reduce it to_ `1` _under the following rules_:

*   If the current number is even, you have to divide it by `2`.
    
*   If the current number is odd, you have to add `1` to it.
    

It is guaranteed that you can always reach one for all test cases.

**Example 1:**

**Input:** s =  "1101 "
**Output:** 6
**Explanation:**  "1101 " corressponds to number 13 in their decimal representation.
Step 1) 13 is odd, add 1 and obtain 14. 
Step 2) 14 is even, divide by 2 and obtain 7.
Step 3) 7 is odd, add 1 and obtain 8.
Step 4) 8 is even, divide by 2 and obtain 4.  
Step 5) 4 is even, divide by 2 and obtain 2. 
Step 6) 2 is even, divide by 2 and obtain 1.  

**Example 2:**

**Input:** s =  "10 "
**Output:** 1
**Explanation:**  "10 " corressponds to number 2 in their decimal representation.
Step 1) 2 is even, divide by 2 and obtain 1.  

**Example 3:**

**Input:** s =  "1 "
**Output:** 0

**Constraints:**

*   `1 <= s.length <= 500`
*   `s` consists of characters '0' or '1'
*   `s[0] == '1'`
Longest Happy String

A string `s` is called **happy** if it satisfies the following conditions:

*   `s` only contains the letters `'a'`, `'b'`, and `'c'`.
*   `s` does not contain any of `"aaa "`, `"bbb "`, or `"ccc "` as a substring.
*   `s` contains **at most** `a` occurrences of the letter `'a'`.
*   `s` contains **at most** `b` occurrences of the letter `'b'`.
*   `s` contains **at most** `c` occurrences of the letter `'c'`.

Given three integers `a`, `b`, and `c`, return _the **longest possible happy** string_. If there are multiple longest happy strings, return _any of them_. If there is no such string, return _the empty string_ `" "`.

A **substring** is a contiguous sequence of characters within a string.

**Example 1:**

**Input:** a = 1, b = 1, c = 7
**Output:**  "ccaccbcc "
**Explanation:**  "ccbccacc " would also be a correct answer.

**Example 2:**

**Input:** a = 7, b = 1, c = 0
**Output:**  "aabaa "
**Explanation:** It is the only correct answer in this case.

**Constraints:**

*   `0 <= a, b, c <= 100`
*   `a + b + c > 0`
Stone Game III

Alice and Bob continue their games with piles of stones. There are several stones **arranged in a row**, and each stone has an associated value which is an integer given in the array `stoneValue`.

Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take `1`, `2`, or `3` stones from the **first** remaining stones in the row.

The score of each player is the sum of the values of the stones taken. The score of each player is `0` initially.

The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.

Assume Alice and Bob **play optimally**.

Return `"Alice "` _if Alice will win,_ `"Bob "` _if Bob will win, or_ `"Tie "` _if they will end the game with the same score_.

**Example 1:**

**Input:** values = \[1,2,3,7\]
**Output:**  "Bob "
**Explanation:** Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.

**Example 2:**

**Input:** values = \[1,2,3,-9\]
**Output:**  "Alice "
**Explanation:** Alice must choose all the three piles at the first move to win and leave Bob with negative score.
If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.
If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.
Remember that both play optimally so here Alice will choose the scenario that makes her win.

**Example 3:**

**Input:** values = \[1,2,3,6\]
**Output:**  "Tie "
**Explanation:** Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.

**Constraints:**

*   `1 <= stoneValue.length <= 5 * 104`
*   `-1000 <= stoneValue[i] <= 1000`
String Matching in an Array

Given an array of string `words`, return _all strings in_ `words` _that is a **substring** of another word_. You can return the answer in **any order**.

A **substring** is a contiguous sequence of characters within a string

**Example 1:**

**Input:** words = \[ "mass ", "as ", "hero ", "superhero "\]
**Output:** \[ "as ", "hero "\]
**Explanation:**  "as " is substring of  "mass " and  "hero " is substring of  "superhero ".
\[ "hero ", "as "\] is also a valid answer.

**Example 2:**

**Input:** words = \[ "leetcode ", "et ", "code "\]
**Output:** \[ "et ", "code "\]
**Explanation:**  "et ",  "code " are substring of  "leetcode ".

**Example 3:**

**Input:** words = \[ "blue ", "green ", "bu "\]
**Output:** \[\]
**Explanation:** No string of words is substring of another string.

**Constraints:**

*   `1 <= words.length <= 100`
*   `1 <= words[i].length <= 30`
*   `words[i]` contains only lowercase English letters.
*   All the strings of `words` are **unique**.
Queries on a Permutation With Key

Given the array `queries` of positive integers between `1` and `m`, you have to process all `queries[i]` (from `i=0` to `i=queries.length-1`) according to the following rules:

*   In the beginning, you have the permutation `P=[1,2,3,...,m]`.
*   For the current `i`, find the position of `queries[i]` in the permutation `P` (**indexing from 0**) and then move this at the beginning of the permutation `P.` Notice that the position of `queries[i]` in `P` is the result for `queries[i]`.

Return an array containing the result for the given `queries`.

**Example 1:**

**Input:** queries = \[3,1,2,1\], m = 5
**Output:** \[2,1,2,1\] 
**Explanation:** The queries are processed as follow: 
For i=0: queries\[i\]=3, P=\[1,2,3,4,5\], position of 3 in P is **2**, then we move 3 to the beginning of P resulting in P=\[3,1,2,4,5\]. 
For i=1: queries\[i\]=1, P=\[3,1,2,4,5\], position of 1 in P is **1**, then we move 1 to the beginning of P resulting in P=\[1,3,2,4,5\]. 
For i=2: queries\[i\]=2, P=\[1,3,2,4,5\], position of 2 in P is **2**, then we move 2 to the beginning of P resulting in P=\[2,1,3,4,5\]. 
For i=3: queries\[i\]=1, P=\[2,1,3,4,5\], position of 1 in P is **1**, then we move 1 to the beginning of P resulting in P=\[1,2,3,4,5\]. 
Therefore, the array containing the result is \[2,1,2,1\].  

**Example 2:**

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

**Example 3:**

**Input:** queries = \[7,5,5,8,3\], m = 8
**Output:** \[6,5,0,7,5\]

**Constraints:**

*   `1 <= m <= 10^3`
*   `1 <= queries.length <= m`
*   `1 <= queries[i] <= m`
HTML Entity Parser

**HTML entity parser** is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.

The special characters and their entities for HTML are:

*   **Quotation Mark:** the entity is `&quot;` and symbol character is `"`.
*   **Single Quote Mark:** the entity is `&apos;` and symbol character is `'`.
*   **Ampersand:** the entity is `&amp;` and symbol character is `&`.
*   **Greater Than Sign:** the entity is `&gt;` and symbol character is `>`.
*   **Less Than Sign:** the entity is `&lt;` and symbol character is `<`.
*   **Slash:** the entity is `&frasl;` and symbol character is `/`.

Given the input `text` string to the HTML parser, you have to implement the entity parser.

Return _the text after replacing the entities by the special characters_.

**Example 1:**

**Input:** text =  "&amp; is an HTML entity but &ambassador; is not. "
**Output:**  "& is an HTML entity but &ambassador; is not. "
**Explanation:** The parser will replace the &amp; entity by &

**Example 2:**

**Input:** text =  "and I quote: &quot;...&quot; "
**Output:**  "and I quote: \\ "...\\ " "

**Constraints:**

*   `1 <= text.length <= 105`
*   The string may contain any possible characters out of all the 256 ASCII characters.