bowang0911/leetcode huggingface dataset:
Remove Sub-Folders from the Filesystem

Given a list of folders `folder`, return _the folders after removing all **sub-folders** in those folders_. You may return the answer in **any order**.

If a `folder[i]` is located within another `folder[j]`, it is called a **sub-folder** of it.

The format of a path is one or more concatenated strings of the form: `'/'` followed by one or more lowercase English letters.

*   For example, `"/leetcode "` and `"/leetcode/problems "` are valid paths while an empty string and `"/ "` are not.

**Example 1:**

**Input:** folder = \[ "/a ", "/a/b ", "/c/d ", "/c/d/e ", "/c/f "\]
**Output:** \[ "/a ", "/c/d ", "/c/f "\]
**Explanation:** Folders  "/a/b " is a subfolder of  "/a " and  "/c/d/e " is inside of folder  "/c/d " in our filesystem.

**Example 2:**

**Input:** folder = \[ "/a ", "/a/b/c ", "/a/b/d "\]
**Output:** \[ "/a "\]
**Explanation:** Folders  "/a/b/c " and  "/a/b/d " will be removed because they are subfolders of  "/a ".

**Example 3:**

**Input:** folder = \[ "/a/b/c ", "/a/b/ca ", "/a/b/d "\]
**Output:** \[ "/a/b/c ", "/a/b/ca ", "/a/b/d "\]

**Constraints:**

*   `1 <= folder.length <= 4 * 104`
*   `2 <= folder[i].length <= 100`
*   `folder[i]` contains only lowercase letters and `'/'`.
*   `folder[i]` always starts with the character `'/'`.
*   Each folder name is **unique**.
Replace the Substring for Balanced String

You are given a string s of length `n` containing only four kinds of characters: `'Q'`, `'W'`, `'E'`, and `'R'`.

A string is said to be **balanced** if each of its characters appears `n / 4` times where `n` is the length of the string.

Return _the minimum length of the substring that can be replaced with **any** other string of the same length to make_ `s` _**balanced**_. If s is already **balanced**, return `0`.

**Example 1:**

**Input:** s =  "QWER "
**Output:** 0
**Explanation:** s is already balanced.

**Example 2:**

**Input:** s =  "QQWE "
**Output:** 1
**Explanation:** We need to replace a 'Q' to 'R', so that  "RQWE " (or  "QRWE ") is balanced.

**Example 3:**

**Input:** s =  "QQQW "
**Output:** 2
**Explanation:** We can replace the first  "QQ " to  "ER ". 

**Constraints:**

*   `n == s.length`
*   `4 <= n <= 105`
*   `n` is a multiple of `4`.
*   `s` contains only `'Q'`, `'W'`, `'E'`, and `'R'`.
Maximum Profit in Job Scheduling

We have `n` jobs, where every job is scheduled to be done from `startTime[i]` to `endTime[i]`, obtaining a profit of `profit[i]`.

You're given the `startTime`, `endTime` and `profit` arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range.

If you choose a job that ends at time `X` you will be able to start another job that starts at time `X`.

**Example 1:**

**Input:** startTime = \[1,2,3,3\], endTime = \[3,4,5,6\], profit = \[50,10,40,70\]
**Output:** 120
**Explanation:** The subset chosen is the first and fourth job. 
Time range \[1-3\]+\[3-6\] , we get profit of 120 = 50 + 70.

**Example 2:**

**Input:** startTime = \[1,2,3,4,6\], endTime = \[3,5,10,6,9\], profit = \[20,20,100,70,60\]
**Output:** 150
**Explanation:** The subset chosen is the first, fourth and fifth job. 
Profit obtained 150 = 20 + 70 + 60.

**Example 3:**

**Input:** startTime = \[1,1,1\], endTime = \[2,3,4\], profit = \[5,6,4\]
**Output:** 6

**Constraints:**

*   `1 <= startTime.length == endTime.length == profit.length <= 5 * 104`
*   `1 <= startTime[i] < endTime[i] <= 109`
*   `1 <= profit[i] <= 104`
Web Crawler

Given a url `startUrl` and an interface `HtmlParser`, implement a web crawler to crawl all links that are under the **same hostname** as `startUrl`.

Return all urls obtained by your web crawler in **any** order.

Your crawler should:

*   Start from the page: `startUrl`
*   Call `HtmlParser.getUrls(url)` to get all urls from a webpage of given url.
*   Do not crawl the same link twice.
*   Explore only the links that are under the **same hostname** as `startUrl`.

As shown in the example url above, the hostname is `example.org`. For simplicity sake, you may assume all urls use **http protocol** without any **port** specified. For example, the urls `http://leetcode.com/problems` and `http://leetcode.com/contest` are under the same hostname, while urls `http://example.org/test` and `http://example.com/abc` are not under the same hostname.

The `HtmlParser` interface is defined as such:

interface HtmlParser {
  // Return a list of all urls from a webpage of given _url_.
  public List getUrls(String url);
}

Below are two examples explaining the functionality of the problem, for custom testing purposes you'll have three variables `urls`, `edges` and `startUrl`. Notice that you will only have access to `startUrl` in your code, while `urls` and `edges` are not directly accessible to you in code.

Note: Consider the same URL with the trailing slash "/ " as a different URL. For example, "http://news.yahoo.com ", and "http://news.yahoo.com/ " are different urls.

**Example 1:**

**Input:**
urls = \[
   "http://news.yahoo.com ",
   "http://news.yahoo.com/news ",
   "http://news.yahoo.com/news/topics/ ",
   "http://news.google.com ",
   "http://news.yahoo.com/us "
\]
edges = \[\[2,0\],\[2,1\],\[3,2\],\[3,1\],\[0,4\]\]
startUrl =  "http://news.yahoo.com/news/topics/ "
**Output:** \[
   "http://news.yahoo.com ",
   "http://news.yahoo.com/news ",
   "http://news.yahoo.com/news/topics/ ",
   "http://news.yahoo.com/us "
\]

**Example 2:**

**Input:** 
urls = \[
   "http://news.yahoo.com ",
   "http://news.yahoo.com/news ",
   "http://news.yahoo.com/news/topics/ ",
   "http://news.google.com "
\]
edges = \[\[0,2\],\[2,1\],\[3,2\],\[3,1\],\[3,0\]\]
startUrl =  "http://news.google.com "
**Output:** \[ "http://news.google.com "\]
**Explanation:** The startUrl links to all other pages that do not share the same hostname.

**Constraints:**

*   `1 <= urls.length <= 1000`
*   `1 <= urls[i].length <= 300`
*   `startUrl` is one of the `urls`.
*   Hostname label must be from 1 to 63 characters long, including the dots, may contain only the ASCII letters from 'a' to 'z', digits from '0' to '9' and the hyphen-minus character ('-').
*   The hostname may not start or end with the hyphen-minus character ('-').
*   See: [https://en.wikipedia.org/wiki/Hostname#Restrictions\_on\_valid\_hostnames](https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames)
*   You may assume there're no duplicates in url library.
Find Positive Integer Solution for a Given Equation

Given a callable function `f(x, y)` **with a hidden formula** and a value `z`, reverse engineer the formula and return _all positive integer pairs_ `x` _and_ `y` _where_ `f(x,y) == z`. You may return the pairs in any order.

While the exact formula is hidden, the function is monotonically increasing, i.e.:

*   `f(x, y) < f(x + 1, y)`
*   `f(x, y) < f(x, y + 1)`

The function interface is defined like this:

interface CustomFunction {
public:
  // Returns some positive integer f(x, y) for two positive integers x and y based on a formula.
  int f(int x, int y);
};

We will judge your solution as follows:

*   The judge has a list of `9` hidden implementations of `CustomFunction`, along with a way to generate an **answer key** of all valid pairs for a specific `z`.
*   The judge will receive two inputs: a `function_id` (to determine which implementation to test your code with), and the target `z`.
*   The judge will call your `findSolution` and compare your results with the **answer key**.
*   If your results match the **answer key**, your solution will be `Accepted`.

**Example 1:**

**Input:** function\_id = 1, z = 5
**Output:** \[\[1,4\],\[2,3\],\[3,2\],\[4,1\]\]
**Explanation:** The hidden formula for function\_id = 1 is f(x, y) = x + y.
The following positive integer values of x and y make f(x, y) equal to 5:
x=1, y=4 -> f(1, 4) = 1 + 4 = 5.
x=2, y=3 -> f(2, 3) = 2 + 3 = 5.
x=3, y=2 -> f(3, 2) = 3 + 2 = 5.
x=4, y=1 -> f(4, 1) = 4 + 1 = 5.

**Example 2:**

**Input:** function\_id = 2, z = 5
**Output:** \[\[1,5\],\[5,1\]\]
**Explanation:** The hidden formula for function\_id = 2 is f(x, y) = x \* y.
The following positive integer values of x and y make f(x, y) equal to 5:
x=1, y=5 -> f(1, 5) = 1 \* 5 = 5.
x=5, y=1 -> f(5, 1) = 5 \* 1 = 5.

**Constraints:**

*   `1 <= function_id <= 9`
*   `1 <= z <= 100`
*   It is guaranteed that the solutions of `f(x, y) == z` will be in the range `1 <= x, y <= 1000`.
*   It is also guaranteed that `f(x, y)` will fit in 32 bit signed integer if `1 <= x, y <= 1000`.
Circular Permutation in Binary Representation

Given 2 integers `n` and `start`. Your task is return **any** permutation `p` of `(0,1,2.....,2^n -1)` such that :

*   `p[0] = start`
*   `p[i]` and `p[i+1]` differ by only one bit in their binary representation.
*   `p[0]` and `p[2^n -1]` must also differ by only one bit in their binary representation.

**Example 1:**

**Input:** n = 2, start = 3
**Output:** \[3,2,0,1\]
**Explanation:** The binary representation of the permutation is (11,10,00,01). 
All the adjacent element differ by one bit. Another valid permutation is \[3,1,0,2\]

**Example 2:**

**Input:** n = 3, start = 2
**Output:** \[2,6,7,5,4,0,1,3\]
**Explanation:** The binary representation of the permutation is (010,110,111,101,100,000,001,011).

**Constraints:**

*   `1 <= n <= 16`
*   `0 <= start < 2 ^ n`
Maximum Length of a Concatenated String with Unique Characters

You are given an array of strings `arr`. A string `s` is formed by the **concatenation** of a **subsequence** of `arr` that has **unique characters**.

Return _the **maximum** possible length_ of `s`.

A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

**Example 1:**

**Input:** arr = \[ "un ", "iq ", "ue "\]
**Output:** 4
**Explanation:** All the valid concatenations are:
-  " "
-  "un "
-  "iq "
-  "ue "
-  "uniq " ( "un " +  "iq ")
-  "ique " ( "iq " +  "ue ")
Maximum length is 4.

**Example 2:**

**Input:** arr = \[ "cha ", "r ", "act ", "ers "\]
**Output:** 6
**Explanation:** Possible longest valid concatenations are  "chaers " ( "cha " +  "ers ") and  "acters " ( "act " +  "ers ").

**Example 3:**

**Input:** arr = \[ "abcdefghijklmnopqrstuvwxyz "\]
**Output:** 26
**Explanation:** The only string in arr has all 26 characters.

**Constraints:**

*   `1 <= arr.length <= 16`
*   `1 <= arr[i].length <= 26`
*   `arr[i]` contains only lowercase English letters.
Tiling a Rectangle with the Fewest Squares

Given a rectangle of size `n` x `m`, return _the minimum number of integer-sided squares that tile the rectangle_.

**Example 1:**

**Input:** n = 2, m = 3
**Output:** 3
**Explanation:** `3` squares are necessary to cover the rectangle.
`2` (squares of `1x1`)
`1` (square of `2x2`)

**Example 2:**

**Input:** n = 5, m = 8
**Output:** 5

**Example 3:**

**Input:** n = 11, m = 13
**Output:** 6

**Constraints:**

*   `1 <= n, m <= 13`
Array Transformation

Given an initial array `arr`, every day you produce a new array using the array of the previous day.

On the `i`\-th day, you do the following operations on the array of day `i-1` to produce the array of day `i`:

1.  If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented.
2.  If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented.
3.  The first and last elements never change.

After some days, the array does not change. Return that final array.

**Example 1:**

**Input:** arr = \[6,2,3,4\]
**Output:** \[6,3,3,4\]
**Explanation:** 
On the first day, the array is changed from \[6,2,3,4\] to \[6,3,3,4\].
No more operations can be done to this array.

**Example 2:**

**Input:** arr = \[1,6,3,4,3,5\]
**Output:** \[1,4,4,4,4,5\]
**Explanation:** 
On the first day, the array is changed from \[1,6,3,4,3,5\] to \[1,5,4,3,4,5\].
On the second day, the array is changed from \[1,5,4,3,4,5\] to \[1,4,4,4,4,5\].
No more operations can be done to this array.

**Constraints:**

*   `3 <= arr.length <= 100`
*   `1 <= arr[i] <= 100`
Design A Leaderboard

Design a Leaderboard class, which has 3 functions:

1.  `addScore(playerId, score)`: Update the leaderboard by adding `score` to the given player's score. If there is no player with such id in the leaderboard, add him to the leaderboard with the given `score`.
2.  `top(K)`: Return the score sum of the top `K` players.
3.  `reset(playerId)`: Reset the score of the player with the given id to 0 (in other words erase it from the leaderboard). It is guaranteed that the player was added to the leaderboard before calling this function.

Initially, the leaderboard is empty.

**Example 1:**

**Input:** 
\[ "Leaderboard ", "addScore ", "addScore ", "addScore ", "addScore ", "addScore ", "top ", "reset ", "reset ", "addScore ", "top "\]
\[\[\],\[1,73\],\[2,56\],\[3,39\],\[4,51\],\[5,4\],\[1\],\[1\],\[2\],\[2,51\],\[3\]\]
**Output:** 
\[null,null,null,null,null,null,73,null,null,null,141\]

**Explanation:** 
Leaderboard leaderboard = new Leaderboard ();
leaderboard.addScore(1,73);   // leaderboard = \[\[1,73\]\];
leaderboard.addScore(2,56);   // leaderboard = \[\[1,73\],\[2,56\]\];
leaderboard.addScore(3,39);   // leaderboard = \[\[1,73\],\[2,56\],\[3,39\]\];
leaderboard.addScore(4,51);   // leaderboard = \[\[1,73\],\[2,56\],\[3,39\],\[4,51\]\];
leaderboard.addScore(5,4);    // leaderboard = \[\[1,73\],\[2,56\],\[3,39\],\[4,51\],\[5,4\]\];
leaderboard.top(1);           // returns 73;
leaderboard.reset(1);         // leaderboard = \[\[2,56\],\[3,39\],\[4,51\],\[5,4\]\];
leaderboard.reset(2);         // leaderboard = \[\[3,39\],\[4,51\],\[5,4\]\];
leaderboard.addScore(2,51);   // leaderboard = \[\[2,51\],\[3,39\],\[4,51\],\[5,4\]\];
leaderboard.top(3);           // returns 141 = 51 + 51 + 39;

**Constraints:**

*   `1 <= playerId, K <= 10000`
*   It's guaranteed that `K` is less than or equal to the current number of players.
*   `1 <= score <= 100`
*   There will be at most `1000` function calls.
Tree Diameter

The **diameter** of a tree is **the number of edges** in the longest path in that tree.

There is an undirected tree of `n` nodes labeled from `0` to `n - 1`. You are given a 2D array `edges` where `edges.length == n - 1` and `edges[i] = [ai, bi]` indicates that there is an undirected edge between nodes `ai` and `bi` in the tree.

Return _the **diameter** of the tree_.

**Example 1:**

**Input:** edges = \[\[0,1\],\[0,2\]\]
**Output:** 2
**Explanation:** The longest path of the tree is the path 1 - 0 - 2.

**Example 2:**

**Input:** edges = \[\[0,1\],\[1,2\],\[2,3\],\[1,4\],\[4,5\]\]
**Output:** 4
**Explanation:** The longest path of the tree is the path 3 - 2 - 1 - 4 - 5.

**Constraints:**

*   `n == edges.length + 1`
*   `1 <= n <= 104`
*   `0 <= ai, bi < n`
*   `ai != bi`
Palindrome Removal

You are given an integer array `arr`.

In one move, you can select a **palindromic** subarray `arr[i], arr[i + 1], ..., arr[j]` where `i <= j`, and remove that subarray from the given array. Note that after removing a subarray, the elements on the left and on the right of that subarray move to fill the gap left by the removal.

Return _the minimum number of moves needed to remove all numbers from the array_.

**Example 1:**

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

**Example 2:**

**Input:** arr = \[1,3,4,1,5\]
**Output:** 3
**Explanation:** Remove \[4\] then remove \[1,3,1\] then remove \[5\].

**Constraints:**

*   `1 <= arr.length <= 100`
*   `1 <= arr[i] <= 20`
Minimum Swaps to Make Strings Equal

You are given two strings `s1` and `s2` of equal length consisting of letters `"x "` and `"y "` **only**. Your task is to make these two strings equal to each other. You can swap any two characters that belong to **different** strings, which means: swap `s1[i]` and `s2[j]`.

Return the minimum number of swaps required to make `s1` and `s2` equal, or return `-1` if it is impossible to do so.

**Example 1:**

**Input:** s1 =  "xx ", s2 =  "yy "
**Output:** 1
**Explanation:** Swap s1\[0\] and s2\[1\], s1 =  "yx ", s2 =  "yx ".

**Example 2:**

**Input:** s1 =  "xy ", s2 =  "yx "
**Output:** 2
**Explanation:** Swap s1\[0\] and s2\[0\], s1 =  "yy ", s2 =  "xx ".
Swap s1\[0\] and s2\[1\], s1 =  "xy ", s2 =  "xy ".
Note that you cannot swap s1\[0\] and s1\[1\] to make s1 equal to  "yx ", cause we can only swap chars in different strings.

**Example 3:**

**Input:** s1 =  "xx ", s2 =  "xy "
**Output:** -1

**Constraints:**

*   `1 <= s1.length, s2.length <= 1000`
*   `s1.length == s2.length`
*   `s1, s2` only contain `'x'` or `'y'`.
Count Number of Nice Subarrays

Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it.

Return _the number of **nice** sub-arrays_.

**Example 1:**

**Input:** nums = \[1,1,2,1,1\], k = 3
**Output:** 2
**Explanation:** The only sub-arrays with 3 odd numbers are \[1,1,2,1\] and \[1,2,1,1\].

**Example 2:**

**Input:** nums = \[2,4,6\], k = 1
**Output:** 0
**Explanation:** There is no odd numbers in the array.

**Example 3:**

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

**Constraints:**

*   `1 <= nums.length <= 50000`
*   `1 <= nums[i] <= 10^5`
*   `1 <= k <= nums.length`
Check If It Is a Good Array

Given an array `nums` of positive integers. Your task is to select some subset of `nums`, multiply each element by an integer and add all these numbers. The array is said to be **good** if you can obtain a sum of `1` from the array by any possible subset and multiplicand.

Return `True` if the array is **good** otherwise return `False`.

**Example 1:**

**Input:** nums = \[12,5,7,23\]
**Output:** true
**Explanation:** Pick numbers 5 and 7.
5\*3 + 7\*(-2) = 1

**Example 2:**

**Input:** nums = \[29,6,10\]
**Output:** true
**Explanation:** Pick numbers 29, 6 and 10.
29\*1 + 6\*(-3) + 10\*(-1) = 1

**Example 3:**

**Input:** nums = \[3,6\]
**Output:** false

**Constraints:**

*   `1 <= nums.length <= 10^5`
*   `1 <= nums[i] <= 10^9`
Cells with Odd Values in a Matrix

There is an `m x n` matrix that is initialized to all `0`'s. There is also a 2D array `indices` where each `indices[i] = [ri, ci]` represents a **0-indexed location** to perform some increment operations on the matrix.

For each location `indices[i]`, do **both** of the following:

1.  Increment **all** the cells on row `ri`.
2.  Increment **all** the cells on column `ci`.

Given `m`, `n`, and `indices`, return _the **number of odd-valued cells** in the matrix after applying the increment to all locations in_ `indices`.

**Example 1:**

**Input:** m = 2, n = 3, indices = \[\[0,1\],\[1,1\]\]
**Output:** 6
**Explanation:** Initial matrix = \[\[0,0,0\],\[0,0,0\]\].
After applying first increment it becomes \[\[1,2,1\],\[0,1,0\]\].
The final matrix is \[\[1,3,1\],\[1,3,1\]\], which contains 6 odd numbers.

**Example 2:**

**Input:** m = 2, n = 2, indices = \[\[1,1\],\[0,0\]\]
**Output:** 0
**Explanation:** Final matrix = \[\[2,2\],\[2,2\]\]. There are no odd numbers in the final matrix.

**Constraints:**

*   `1 <= m, n <= 50`
*   `1 <= indices.length <= 100`
*   `0 <= ri < m`
*   `0 <= ci < n`

**Follow up:** Could you solve this in `O(n + m + indices.length)` time with only `O(n + m)` extra space?
Reconstruct a 2-Row Binary Matrix

Given the following details of a matrix with `n` columns and `2` rows :

*   The matrix is a binary matrix, which means each element in the matrix can be `0` or `1`.
*   The sum of elements of the 0-th(upper) row is given as `upper`.
*   The sum of elements of the 1-st(lower) row is given as `lower`.
*   The sum of elements in the i-th column(0-indexed) is `colsum[i]`, where `colsum` is given as an integer array with length `n`.

Your task is to reconstruct the matrix with `upper`, `lower` and `colsum`.

Return it as a 2-D integer array.

If there are more than one valid solution, any of them will be accepted.

If no valid solution exists, return an empty 2-D array.

**Example 1:**

**Input:** upper = 2, lower = 1, colsum = \[1,1,1\]
**Output:** \[\[1,1,0\],\[0,0,1\]\]
**Explanation:** \[\[1,0,1\],\[0,1,0\]\], and \[\[0,1,1\],\[1,0,0\]\] are also correct answers.

**Example 2:**

**Input:** upper = 2, lower = 3, colsum = \[2,2,1,1\]
**Output:** \[\]

**Example 3:**

**Input:** upper = 5, lower = 5, colsum = \[2,1,2,0,1,0,1,2,0,1\]
**Output:** \[\[1,1,1,0,1,0,0,1,0,0\],\[1,0,1,0,0,0,1,1,0,1\]\]

**Constraints:**

*   `1 <= colsum.length <= 10^5`
*   `0 <= upper, lower <= colsum.length`
*   `0 <= colsum[i] <= 2`
Number of Closed Islands

Given a 2D `grid` consists of `0s` (land) and `1s` (water). An _island_ is a maximal 4-directionally connected group of `0s` and a _closed island_ is an island **totally** (all left, top, right, bottom) surrounded by `1s.`

Return the number of _closed islands_.

**Example 1:**

**Input:** grid = \[\[1,1,1,1,1,1,1,0\],\[1,0,0,0,0,1,1,0\],\[1,0,1,0,1,1,1,0\],\[1,0,0,0,0,1,0,1\],\[1,1,1,1,1,1,1,0\]\]
**Output:** 2
**Explanation:** 
Islands in gray are closed because they are completely surrounded by water (group of 1s).

**Example 2:**

**Input:** grid = \[\[0,0,1,0,0\],\[0,1,0,1,0\],\[0,1,1,1,0\]\]
**Output:** 1

**Example 3:**

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

**Constraints:**

*   `1 <= grid.length, grid[0].length <= 100`
*   `0 <= grid[i][j] <=1`
Maximum Score Words Formed by Letters

Given a list of `words`, list of single `letters` (might be repeating) and `score` of every character.

Return the maximum score of **any** valid set of words formed by using the given letters (`words[i]` cannot be used two or more times).

It is not necessary to use all characters in `letters` and each letter can only be used once. Score of letters `'a'`, `'b'`, `'c'`, ... ,`'z'` is given by `score[0]`, `score[1]`, ... , `score[25]` respectively.

**Example 1:**

**Input:** words = \[ "dog ", "cat ", "dad ", "good "\], letters = \[ "a ", "a ", "c ", "d ", "d ", "d ", "g ", "o ", "o "\], score = \[1,0,9,5,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0\]
**Output:** 23
**Explanation:**
Score  a=1, c=9, d=5, g=3, o=2
Given letters, we can form the words  "dad " (5+1+5) and  "good " (3+2+2+5) with a score of 23.
Words  "dad " and  "dog " only get a score of 21.

**Example 2:**

**Input:** words = \[ "xxxz ", "ax ", "bx ", "cx "\], letters = \[ "z ", "a ", "b ", "c ", "x ", "x ", "x "\], score = \[4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,10\]
**Output:** 27
**Explanation:**
Score  a=4, b=4, c=4, x=5, z=10
Given letters, we can form the words  "ax " (4+5),  "bx " (4+5) and  "cx " (4+5) with a score of 27.
Word  "xxxz " only get a score of 25.

**Example 3:**

**Input:** words = \[ "leetcode "\], letters = \[ "l ", "e ", "t ", "c ", "o ", "d "\], score = \[0,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0\]
**Output:** 0
**Explanation:**
Letter  "e " can only be used once.

**Constraints:**

*   `1 <= words.length <= 14`
*   `1 <= words[i].length <= 15`
*   `1 <= letters.length <= 100`
*   `letters[i].length == 1`
*   `score.length == 26`
*   `0 <= score[i] <= 10`
*   `words[i]`, `letters[i]` contains only lower case English letters.
Encode Number

Given a non-negative integer `num`, Return its _encoding_ string.

The encoding is done by converting the integer to a string using a secret function that you should deduce from the following table:

**Example 1:**

**Input:** num = 23
**Output:**  "1000 "

**Example 2:**

**Input:** num = 107
**Output:**  "101100 "

**Constraints:**

*   `0 <= num <= 10^9`

\- Rank is an integer starting from 1. - The larger the element, the larger the rank. If two elements are the same, their rank must be the same. - Rank should be as small as possible. Function signature: \`int\[\] arrayRankTransform(int\[\] arr)\`