bowang0911/leetcode huggingface dataset:
Design Authentication Manager

There is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will expire `timeToLive` seconds after the `currentTime`. If the token is renewed, the expiry time will be **extended** to expire `timeToLive` seconds after the (potentially different) `currentTime`.

Implement the `AuthenticationManager` class:

*   `AuthenticationManager(int timeToLive)` constructs the `AuthenticationManager` and sets the `timeToLive`.
*   `generate(string tokenId, int currentTime)` generates a new token with the given `tokenId` at the given `currentTime` in seconds.
*   `renew(string tokenId, int currentTime)` renews the **unexpired** token with the given `tokenId` at the given `currentTime` in seconds. If there are no unexpired tokens with the given `tokenId`, the request is ignored, and nothing happens.
*   `countUnexpiredTokens(int currentTime)` returns the number of **unexpired** tokens at the given currentTime.

Note that if a token expires at time `t`, and another action happens on time `t` (`renew` or `countUnexpiredTokens`), the expiration takes place **before** the other actions.

**Example 1:**

**Input**
\[ "AuthenticationManager ",  "`renew` ",  "generate ",  "`countUnexpiredTokens` ",  "generate ",  "`renew` ",  "`renew` ",  "`countUnexpiredTokens` "\]
\[\[5\], \[ "aaa ", 1\], \[ "aaa ", 2\], \[6\], \[ "bbb ", 7\], \[ "aaa ", 8\], \[ "bbb ", 10\], \[15\]\]
**Output**
\[null, null, null, 1, null, null, null, 0\]

**Explanation**
AuthenticationManager authenticationManager = new AuthenticationManager(5); // Constructs the AuthenticationManager with `timeToLive` = 5 seconds.
authenticationManager.`renew`( "aaa ", 1); // No token exists with tokenId  "aaa " at time 1, so nothing happens.
authenticationManager.generate( "aaa ", 2); // Generates a new token with tokenId  "aaa " at time 2.
authenticationManager.`countUnexpiredTokens`(6); // The token with tokenId  "aaa " is the only unexpired one at time 6, so return 1.
authenticationManager.generate( "bbb ", 7); // Generates a new token with tokenId  "bbb " at time 7.
authenticationManager.`renew`( "aaa ", 8); // The token with tokenId  "aaa " expired at time 7, and 8 >= 7, so at time 8 the `renew` request is ignored, and nothing happens.
authenticationManager.`renew`( "bbb ", 10); // The token with tokenId  "bbb " is unexpired at time 10, so the `renew` request is fulfilled and now the token will expire at time 15.
authenticationManager.`countUnexpiredTokens`(15); // The token with tokenId  "bbb " expires at time 15, and the token with tokenId  "aaa " expired at time 7, so currently no token is unexpired, so return 0.

**Constraints:**

*   `1 <= timeToLive <= 108`
*   `1 <= currentTime <= 108`
*   `1 <= tokenId.length <= 5`
*   `tokenId` consists only of lowercase letters.
*   All calls to `generate` will contain unique values of `tokenId`.
*   The values of `currentTime` across all the function calls will be **strictly increasing**.
*   At most `2000` calls will be made to all functions combined.
Maximum Number of Consecutive Values You Can Make

You are given an integer array `coins` of length `n` which represents the `n` coins that you own. The value of the `ith` coin is `coins[i]`. You can **make** some value `x` if you can choose some of your `n` coins such that their values sum up to `x`.

Return the _maximum number of consecutive integer values that you **can** **make** with your coins **starting** from and **including**_ `0`.

Note that you may have multiple coins of the same value.

**Example 1:**

**Input:** coins = \[1,3\]
**Output:** 2
**Explanation:** You can make the following values:
- 0: take \[\]
- 1: take \[1\]
You can make 2 consecutive integer values starting from 0.

**Example 2:**

**Input:** coins = \[1,1,1,4\]
**Output:** 8
**Explanation:** You can make the following values:
- 0: take \[\]
- 1: take \[1\]
- 2: take \[1,1\]
- 3: take \[1,1,1\]
- 4: take \[4\]
- 5: take \[4,1\]
- 6: take \[4,1,1\]
- 7: take \[4,1,1,1\]
You can make 8 consecutive integer values starting from 0.

**Example 3:**

**Input:** nums = \[1,4,10,3,1\]
**Output:** 20

**Constraints:**

*   `coins.length == n`
*   `1 <= n <= 4 * 104`
*   `1 <= coins[i] <= 4 * 104`
Maximize Score After N Operations

You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array.

In the `ith` operation **(1-indexed)**, you will:

*   Choose two elements, `x` and `y`.
*   Receive a score of `i * gcd(x, y)`.
*   Remove `x` and `y` from `nums`.

Return _the maximum score you can receive after performing_ `n` _operations._

The function `gcd(x, y)` is the greatest common divisor of `x` and `y`.

**Example 1:**

**Input:** nums = \[1,2\]
**Output:** 1
**Explanation:** The optimal choice of operations is:
(1 \* gcd(1, 2)) = 1

**Example 2:**

**Input:** nums = \[3,4,6,8\]
**Output:** 11
**Explanation:** The optimal choice of operations is:
(1 \* gcd(3, 6)) + (2 \* gcd(4, 8)) = 3 + 8 = 11

**Example 3:**

**Input:** nums = \[1,2,3,4,5,6\]
**Output:** 14
**Explanation:** The optimal choice of operations is:
(1 \* gcd(1, 5)) + (2 \* gcd(2, 4)) + (3 \* gcd(3, 6)) = 1 + 4 + 9 = 14

**Constraints:**

*   `1 <= n <= 7`
*   `nums.length == 2 * n`
*   `1 <= nums[i] <= 106`
Maximum Ascending Subarray Sum

Given an array of positive integers `nums`, return the _maximum possible sum of an **ascending** subarray in_ `nums`.

A subarray is defined as a contiguous sequence of numbers in an array.

A subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is **ascending** if for all `i` where `l <= i < r`, `numsi < numsi+1`. Note that a subarray of size `1` is **ascending**.

**Example 1:**

**Input:** nums = \[10,20,30,5,10,50\]
**Output:** 65
**Explanation:** \[5,10,50\] is the ascending subarray with the maximum sum of 65.

**Example 2:**

**Input:** nums = \[10,20,30,40,50\]
**Output:** 150
**Explanation:** \[10,20,30,40,50\] is the ascending subarray with the maximum sum of 150.

**Example 3:**

**Input:** nums = \[12,17,15,13,10,11,12\]
**Output:** 33
**Explanation:** \[10,11,12\] is the ascending subarray with the maximum sum of 33.

**Constraints:**

*   `1 <= nums.length <= 100`
*   `1 <= nums[i] <= 100`
Maximum Value at a Given Index in a Bounded Array

You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions:

*   `nums.length == n`
*   `nums[i]` is a **positive** integer where `0 <= i < n`.
*   `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`.
*   The sum of all the elements of `nums` does not exceed `maxSum`.
*   `nums[index]` is **maximized**.

Return `nums[index]` _of the constructed array_.

Note that `abs(x)` equals `x` if `x >= 0`, and `-x` otherwise.

**Example 1:**

**Input:** n = 4, index = 2,  maxSum = 6
**Output:** 2
**Explanation:** nums = \[1,2,**2**,1\] is one array that satisfies all the conditions.
There are no arrays that satisfy all the conditions and have nums\[2\] == 3, so 2 is the maximum nums\[2\].

**Example 2:**

**Input:** n = 6, index = 1,  maxSum = 10
**Output:** 3

**Constraints:**

*   `1 <= n <= maxSum <= 109`
*   `0 <= index < n`
Count Pairs With XOR in a Range

Given a **(0-indexed)** integer array `nums` and two integers `low` and `high`, return _the number of **nice pairs**_.

A **nice pair** is a pair `(i, j)` where `0 <= i < j < nums.length` and `low <= (nums[i] XOR nums[j]) <= high`.

**Example 1:**

**Input:** nums = \[1,4,2,7\], low = 2, high = 6
**Output:** 6
**Explanation:** All nice pairs (i, j) are as follows:
    - (0, 1): nums\[0\] XOR nums\[1\] = 5 
    - (0, 2): nums\[0\] XOR nums\[2\] = 3
    - (0, 3): nums\[0\] XOR nums\[3\] = 6
    - (1, 2): nums\[1\] XOR nums\[2\] = 6
    - (1, 3): nums\[1\] XOR nums\[3\] = 3
    - (2, 3): nums\[2\] XOR nums\[3\] = 5

**Example 2:**

**Input:** nums = \[9,8,4,2,1\], low = 5, high = 14
**Output:** 8
**Explanation:** All nice pairs (i, j) are as follows:
​​​​​    - (0, 2): nums\[0\] XOR nums\[2\] = 13
    - (0, 3): nums\[0\] XOR nums\[3\] = 11
    - (0, 4): nums\[0\] XOR nums\[4\] = 8
    - (1, 2): nums\[1\] XOR nums\[2\] = 12
    - (1, 3): nums\[1\] XOR nums\[3\] = 10
    - (1, 4): nums\[1\] XOR nums\[4\] = 9
    - (2, 3): nums\[2\] XOR nums\[3\] = 6
    - (2, 4): nums\[2\] XOR nums\[4\] = 5

**Constraints:**

*   `1 <= nums.length <= 2 * 104`
*   `1 <= nums[i] <= 2 * 104`
*   `1 <= low <= high <= 2 * 104`
Number of Different Integers in a String

You are given a string `word` that consists of digits and lowercase English letters.

You will replace every non-digit character with a space. For example, `"a123bc34d8ef34 "` will become `" 123 34 8 34 "`. Notice that you are left with some integers that are separated by at least one space: `"123 "`, `"34 "`, `"8 "`, and `"34 "`.

Return _the number of **different** integers after performing the replacement operations on_ `word`.

Two integers are considered different if their decimal representations **without any leading zeros** are different.

**Example 1:**

**Input:** word =  "a123bc34d8ef34 "
**Output:** 3
**Explanation:** The three different integers are  "123 ",  "34 ", and  "8 ". Notice that  "34 " is only counted once.

**Example 2:**

**Input:** word =  "leet1234code234 "
**Output:** 2

**Example 3:**

**Input:** word =  "a1b01c001 "
**Output:** 1
**Explanation:** The three integers  "1 ",  "01 ", and  "001 " all represent the same integer because
the leading zeros are ignored when comparing their decimal values.

**Constraints:**

*   `1 <= word.length <= 1000`
*   `word` consists of digits and lowercase English letters.
Minimum Number of Operations to Reinitialize a Permutation

You are given an **even** integer `n`​​​​​​. You initially have a permutation `perm` of size `n`​​ where `perm[i] == i`​ **(0-indexed)**​​​​.

In one operation, you will create a new array `arr`, and for each `i`:

*   If `i % 2 == 0`, then `arr[i] = perm[i / 2]`.
*   If `i % 2 == 1`, then `arr[i] = perm[n / 2 + (i - 1) / 2]`.

You will then assign `arr`​​​​ to `perm`.

Return _the minimum **non-zero** number of operations you need to perform on_ `perm` _to return the permutation to its initial value._

**Example 1:**

**Input:** n = 2
**Output:** 1
**Explanation:** perm = \[0,1\] initially.
After the 1st operation, perm = \[0,1\]
So it takes only 1 operation.

**Example 2:**

**Input:** n = 4
**Output:** 2
**Explanation:** perm = \[0,1,2,3\] initially.
After the 1st operation, perm = \[0,2,1,3\]
After the 2nd operation, perm = \[0,1,2,3\]
So it takes only 2 operations.

**Example 3:**

**Input:** n = 6
**Output:** 4

**Constraints:**

*   `2 <= n <= 1000`
*   `n`​​​​​​ is even.
Evaluate the Bracket Pairs of a String

You are given a string `s` that contains some bracket pairs, with each pair containing a **non-empty** key.

*   For example, in the string `"(name)is(age)yearsold "`, there are **two** bracket pairs that contain the keys `"name "` and `"age "`.

You know the values of a wide range of keys. This is represented by a 2D string array `knowledge` where each `knowledge[i] = [keyi, valuei]` indicates that key `keyi` has a value of `valuei`.

You are tasked to evaluate **all** of the bracket pairs. When you evaluate a bracket pair that contains some key `keyi`, you will:

*   Replace `keyi` and the bracket pair with the key's corresponding `valuei`.
*   If you do not know the value of the key, you will replace `keyi` and the bracket pair with a question mark `"? "` (without the quotation marks).

Each key will appear at most once in your `knowledge`. There will not be any nested brackets in `s`.

Return _the resulting string after evaluating **all** of the bracket pairs._

**Example 1:**

**Input:** s =  "(name)is(age)yearsold ", knowledge = \[\[ "name ", "bob "\],\[ "age ", "two "\]\]
**Output:**  "bobistwoyearsold "
**Explanation:**
The key  "name " has a value of  "bob ", so replace  "(name) " with  "bob ".
The key  "age " has a value of  "two ", so replace  "(age) " with  "two ".

**Example 2:**

**Input:** s =  "hi(name) ", knowledge = \[\[ "a ", "b "\]\]
**Output:**  "hi? "
**Explanation:** As you do not know the value of the key  "name ", replace  "(name) " with  "? ".

**Example 3:**

**Input:** s =  "(a)(a)(a)aaa ", knowledge = \[\[ "a ", "yes "\]\]
**Output:**  "yesyesyesaaa "
**Explanation:** The same key can appear multiple times.
The key  "a " has a value of  "yes ", so replace all occurrences of  "(a) " with  "yes ".
Notice that the  "a "s not in a bracket pair are not evaluated.

**Constraints:**

*   `1 <= s.length <= 105`
*   `0 <= knowledge.length <= 105`
*   `knowledge[i].length == 2`
*   `1 <= keyi.length, valuei.length <= 10`
*   `s` consists of lowercase English letters and round brackets `'('` and `')'`.
*   Every open bracket `'('` in `s` will have a corresponding close bracket `')'`.
*   The key in each bracket pair of `s` will be non-empty.
*   There will not be any nested bracket pairs in `s`.
*   `keyi` and `valuei` consist of lowercase English letters.
*   Each `keyi` in `knowledge` is unique.
Maximize Number of Nice Divisors

You are given a positive integer `primeFactors`. You are asked to construct a positive integer `n` that satisfies the following conditions:

*   The number of prime factors of `n` (not necessarily distinct) is **at most** `primeFactors`.
*   The number of nice divisors of `n` is maximized. Note that a divisor of `n` is **nice** if it is divisible by every prime factor of `n`. For example, if `n = 12`, then its prime factors are `[2,2,3]`, then `6` and `12` are nice divisors, while `3` and `4` are not.

Return _the number of nice divisors of_ `n`. Since that number can be too large, return it **modulo** `109 + 7`.

Note that a prime number is a natural number greater than `1` that is not a product of two smaller natural numbers. The prime factors of a number `n` is a list of prime numbers such that their product equals `n`.

**Example 1:**

**Input:** primeFactors = 5
**Output:** 6
**Explanation:** 200 is a valid value of n.
It has 5 prime factors: \[2,2,2,5,5\], and it has 6 nice divisors: \[10,20,40,50,100,200\].
There is not other value of n that has at most 5 prime factors and more nice divisors.

**Example 2:**

**Input:** primeFactors = 8
**Output:** 18

**Constraints:**

*   `1 <= primeFactors <= 109`
Determine Color of a Chessboard Square

You are given `coordinates`, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.

Return `true` _if the square is white, and_ `false` _if the square is black_.

The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.

**Example 1:**

**Input:** coordinates =  "a1 "
**Output:** false
**Explanation:** From the chessboard above, the square with coordinates  "a1 " is black, so return false.

**Example 2:**

**Input:** coordinates =  "h3 "
**Output:** true
**Explanation:** From the chessboard above, the square with coordinates  "h3 " is white, so return true.

**Example 3:**

**Input:** coordinates =  "c7 "
**Output:** false

**Constraints:**

*   `coordinates.length == 2`
*   `'a' <= coordinates[0] <= 'h'`
*   `'1' <= coordinates[1] <= '8'`
Sentence Similarity III

A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, `"Hello World "`, `"HELLO "`, `"hello world hello world "` are all sentences. Words consist of **only** uppercase and lowercase English letters.

Two sentences `sentence1` and `sentence2` are **similar** if it is possible to insert an arbitrary sentence **(possibly empty)** inside one of these sentences such that the two sentences become equal. For example, `sentence1 = "Hello my name is Jane "` and `sentence2 = "Hello Jane "` can be made equal by inserting `"my name is "` between `"Hello "` and `"Jane "` in `sentence2`.

Given two sentences `sentence1` and `sentence2`, return `true` _if_ `sentence1` _and_ `sentence2` _are similar._ Otherwise, return `false`.

**Example 1:**

**Input:** sentence1 =  "My name is Haley ", sentence2 =  "My Haley "
**Output:** true
**Explanation:** sentence2 can be turned to sentence1 by inserting  "name is " between  "My " and  "Haley ".

**Example 2:**

**Input:** sentence1 =  "of ", sentence2 =  "A lot of words "
**Output:** false
**Explanation:** No single sentence can be inserted inside one of the sentences to make it equal to the other.

**Example 3:**

**Input:** sentence1 =  "Eating right now ", sentence2 =  "Eating "
**Output:** true
**Explanation:** sentence2 can be turned to sentence1 by inserting  "right now " at the end of the sentence.

**Constraints:**

*   `1 <= sentence1.length, sentence2.length <= 100`
*   `sentence1` and `sentence2` consist of lowercase and uppercase English letters and spaces.
*   The words in `sentence1` and `sentence2` are separated by a single space.
Count Nice Pairs in an Array

You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions:

*   `0 <= i < j < nums.length`
*   `nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])`

Return _the number of nice pairs of indices_. Since that number can be too large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** nums = \[42,11,1,97\]
**Output:** 2
**Explanation:** The two pairs are:
 - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.
 - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.

**Example 2:**

**Input:** nums = \[13,10,35,24,76\]
**Output:** 4

**Constraints:**

*   `1 <= nums.length <= 105`
*   `0 <= nums[i] <= 109`
Maximum Number of Groups Getting Fresh Donuts

There is a donuts shop that bakes donuts in batches of `batchSize`. They have a rule where they must serve **all** of the donuts of a batch before serving any donuts of the next batch. You are given an integer `batchSize` and an integer array `groups`, where `groups[i]` denotes that there is a group of `groups[i]` customers that will visit the shop. Each customer will get exactly one donut.

When a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.

You can freely rearrange the ordering of the groups. Return _the **maximum** possible number of happy groups after rearranging the groups._

**Example 1:**

**Input:** batchSize = 3, groups = \[1,2,3,4,5,6\]
**Output:** 4
**Explanation:** You can arrange the groups as \[6,2,4,5,1,3\]. Then the 1st, 2nd, 4th, and 6th groups will be happy.

**Example 2:**

**Input:** batchSize = 4, groups = \[1,3,2,5,2,2,1,6\]
**Output:** 4

**Constraints:**

*   `1 <= batchSize <= 9`
*   `1 <= groups.length <= 30`
*   `1 <= groups[i] <= 109`
Truncate Sentence

A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of **only** uppercase and lowercase English letters (no punctuation).

*   For example, `"Hello World "`, `"HELLO "`, and `"hello world hello world "` are all sentences.

You are given a sentence `s`​​​​​​ and an integer `k`​​​​​​. You want to **truncate** `s`​​​​​​ such that it contains only the **first** `k`​​​​​​ words. Return `s`​​​​_​​ after **truncating** it._

**Example 1:**

**Input:** s =  "Hello how are you Contestant ", k = 4
**Output:**  "Hello how are you "
**Explanation:**
The words in s are \[ "Hello ",  "how "  "are ",  "you ",  "Contestant "\].
The first 4 words are \[ "Hello ",  "how ",  "are ",  "you "\].
Hence, you should return  "Hello how are you ".

**Example 2:**

**Input:** s =  "What is the solution to this problem ", k = 4
**Output:**  "What is the solution "
**Explanation:**
The words in s are \[ "What ",  "is "  "the ",  "solution ",  "to ",  "this ",  "problem "\].
The first 4 words are \[ "What ",  "is ",  "the ",  "solution "\].
Hence, you should return  "What is the solution ".

**Example 3:**

**Input:** s =  "chopper is not a tanuki ", k = 5
**Output:**  "chopper is not a tanuki "

**Constraints:**

*   `1 <= s.length <= 500`
*   `k` is in the range `[1, the number of words in s]`.
*   `s` consist of only lowercase and uppercase English letters and spaces.
*   The words in `s` are separated by a single space.
*   There are no leading or trailing spaces.
Finding the Users Active Minutes

You are given the logs for users' actions on LeetCode, and an integer `k`. The logs are represented by a 2D integer array `logs` where each `logs[i] = [IDi, timei]` indicates that the user with `IDi` performed an action at the minute `timei`.

**Multiple users** can perform actions simultaneously, and a single user can perform **multiple actions** in the same minute.

The **user active minutes (UAM)** for a given user is defined as the **number of unique minutes** in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.

You are to calculate a **1-indexed** array `answer` of size `k` such that, for each `j` (`1 <= j <= k`), `answer[j]` is the **number of users** whose **UAM** equals `j`.

Return _the array_ `answer` _as described above_.

**Example 1:**

**Input:** logs = \[\[0,5\],\[1,2\],\[0,2\],\[0,5\],\[1,3\]\], k = 5
**Output:** \[0,2,0,0,0\]
**Explanation:**
The user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).
The user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
Since both users have a UAM of 2, answer\[2\] is 2, and the remaining answer\[j\] values are 0.

**Example 2:**

**Input:** logs = \[\[1,1\],\[2,2\],\[2,3\]\], k = 4
**Output:** \[1,1,0,0\]
**Explanation:**
The user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.
The user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
There is one user with a UAM of 1 and one with a UAM of 2.
Hence, answer\[1\] = 1, answer\[2\] = 1, and the remaining values are 0.

**Constraints:**

*   `1 <= logs.length <= 104`
*   `0 <= IDi <= 109`
*   `1 <= timei <= 105`
*   `k` is in the range `[The maximum **UAM** for a user, 105]`.
Minimum Absolute Sum Difference

You are given two positive integer arrays `nums1` and `nums2`, both of length `n`.

The **absolute sum difference** of arrays `nums1` and `nums2` is defined as the **sum** of `|nums1[i] - nums2[i]|` for each `0 <= i < n` (**0-indexed**).

You can replace **at most one** element of `nums1` with **any** other element in `nums1` to **minimize** the absolute sum difference.

Return the _minimum absolute sum difference **after** replacing at most one element in the array `nums1`._ Since the answer may be large, return it **modulo** `109 + 7`.

`|x|` is defined as:

*   `x` if `x >= 0`, or
*   `-x` if `x < 0`.

**Example 1:**

**Input:** nums1 = \[1,7,5\], nums2 = \[2,3,5\]
**Output:** 3
**Explanation:** There are two possible optimal solutions:
- Replace the second element with the first: \[1,**7**,5\] => \[1,**1**,5\], or
- Replace the second element with the third: \[1,**7**,5\] => \[1,**5**,5\].
Both will yield an absolute sum difference of `|1-2| + (|1-3| or |5-3|) + |5-5| =` 3.

**Example 2:**

**Input:** nums1 = \[2,4,6,8,10\], nums2 = \[2,4,6,8,10\]
**Output:** 0
**Explanation:** nums1 is equal to nums2 so no replacement is needed. This will result in an 
absolute sum difference of 0.

**Example 3:**

**Input:** nums1 = \[1,10,4,4,2,7\], nums2 = \[9,3,5,1,7,4\]
**Output:** 20
**Explanation:** Replace the first element with the second: \[**1**,10,4,4,2,7\] => \[**10**,10,4,4,2,7\].
This yields an absolute sum difference of `|10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20`

**Constraints:**

*   `n == nums1.length`
*   `n == nums2.length`
*   `1 <= n <= 105`
*   `1 <= nums1[i], nums2[i] <= 105`