bowang0911/leetcode huggingface dataset:
Sort the Students by Their Kth Score

There is a class with `m` students and `n` exams. You are given a **0-indexed** `m x n` integer matrix `score`, where each row represents one student and `score[i][j]` denotes the score the `ith` student got in the `jth` exam. The matrix `score` contains **distinct** integers only.

You are also given an integer `k`. Sort the students (i.e., the rows of the matrix) by their scores in the `kth` (**0-indexed**) exam from the highest to the lowest.

Return _the matrix after sorting it._

**Example 1:**

**Input:** score = \[\[10,6,9,1\],\[7,5,11,2\],\[4,8,3,15\]\], k = 2
**Output:** \[\[7,5,11,2\],\[10,6,9,1\],\[4,8,3,15\]\]
**Explanation:** In the above diagram, S denotes the student, while E denotes the exam.
- The student with index 1 scored 11 in exam 2, which is the highest score, so they got first place.
- The student with index 0 scored 9 in exam 2, which is the second highest score, so they got second place.
- The student with index 2 scored 3 in exam 2, which is the lowest score, so they got third place.

**Example 2:**

**Input:** score = \[\[3,4\],\[5,6\]\], k = 0
**Output:** \[\[5,6\],\[3,4\]\]
**Explanation:** In the above diagram, S denotes the student, while E denotes the exam.
- The student with index 1 scored 5 in exam 0, which is the highest score, so they got first place.
- The student with index 0 scored 3 in exam 0, which is the lowest score, so they got second place.

**Constraints:**

*   `m == score.length`
*   `n == score[i].length`
*   `1 <= m, n <= 250`
*   `1 <= score[i][j] <= 105`
*   `score` consists of **distinct** integers.
*   `0 <= k < n`
Apply Bitwise Operations to Make Strings Equal

You are given two **0-indexed binary** strings `s` and `target` of the same length `n`. You can do the following operation on `s` **any** number of times:

*   Choose two **different** indices `i` and `j` where `0 <= i, j < n`.
*   Simultaneously, replace `s[i]` with (`s[i]` **OR** `s[j]`) and `s[j]` with (`s[i]` **XOR** `s[j]`).

For example, if `s = "0110 "`, you can choose `i = 0` and `j = 2`, then simultaneously replace `s[0]` with (`s[0]` **OR** `s[2]` = `0` **OR** `1` = `1`), and `s[2]` with (`s[0]` **XOR** `s[2]` = `0` **XOR** `1` = `1`), so we will have `s = "1110 "`.

Return `true` _if you can make the string_ `s` _equal to_ `target`_, or_ `false` _otherwise_.

**Example 1:**

**Input:** s =  "1010 ", target =  "0110 "
**Output:** true
**Explanation:** We can do the following operations:
- Choose i = 2 and j = 0. We have now s =  "**0**0**1**0 ".
- Choose i = 2 and j = 1. We have now s =  "0**11**0 ".
Since we can make s equal to target, we return true.

**Example 2:**

**Input:** s =  "11 ", target =  "00 "
**Output:** false
**Explanation:** It is not possible to make s equal to target with any number of operations.

**Constraints:**

*   `n == s.length == target.length`
*   `2 <= n <= 105`
*   `s` and `target` consist of only the digits `0` and `1`.
Minimum Cost to Split an Array

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

Split the array into some number of non-empty subarrays. The **cost** of a split is the sum of the **importance value** of each subarray in the split.

Let `trimmed(subarray)` be the version of the subarray where all numbers which appear only once are removed.

*   For example, `trimmed([3,1,2,4,3,4]) = [3,4,3,4].`

The **importance value** of a subarray is `k + trimmed(subarray).length`.

*   For example, if a subarray is `[1,2,3,3,3,4,4]`, then trimmed(`[1,2,3,3,3,4,4]) = [3,3,3,4,4].`The importance value of this subarray will be `k + 5`.

Return _the minimum possible cost of a split of_ `nums`.

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

**Example 1:**

**Input:** nums = \[1,2,1,2,1,3,3\], k = 2
**Output:** 8
**Explanation:** We split nums to have two subarrays: \[1,2\], \[1,2,1,3,3\].
The importance value of \[1,2\] is 2 + (0) = 2.
The importance value of \[1,2,1,3,3\] is 2 + (2 + 2) = 6.
The cost of the split is 2 + 6 = 8. It can be shown that this is the minimum possible cost among all the possible splits.

**Example 2:**

**Input:** nums = \[1,2,1,2,1\], k = 2
**Output:** 6
**Explanation:** We split nums to have two subarrays: \[1,2\], \[1,2,1\].
The importance value of \[1,2\] is 2 + (0) = 2.
The importance value of \[1,2,1\] is 2 + (2) = 4.
The cost of the split is 2 + 4 = 6. It can be shown that this is the minimum possible cost among all the possible splits.

**Example 3:**

**Input:** nums = \[1,2,1,2,1\], k = 5
**Output:** 10
**Explanation:** We split nums to have one subarray: \[1,2,1,2,1\].
The importance value of \[1,2,1,2,1\] is 5 + (3 + 2) = 10.
The cost of the split is 10. It can be shown that this is the minimum possible cost among all the possible splits.

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `0 <= nums[i] < nums.length`
*   `1 <= k <= 109`

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0;  } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton\[value="Show Message"\] + .spoiler > div {margin-top:-500%;} .spoilerbutton\[value="Hide Message"\] + .spoiler {padding:5px;}
Maximum Price to Fill a Bag

You are given a 2D integer array `items` where `items[i] = [pricei, weighti]` denotes the price and weight of the `ith` item, respectively.

You are also given a **positive** integer `capacity`.

Each item can be divided into two items with ratios `part1` and `part2`, where `part1 + part2 == 1`.

*   The weight of the first item is `weighti * part1` and the price of the first item is `pricei * part1`.
*   Similarly, the weight of the second item is `weighti * part2` and the price of the second item is `pricei * part2`.

Return _**the maximum total price** to fill a bag of capacity_ `capacity` _with given items_. If it is impossible to fill a bag return `-1`. Answers within `10-5` of the **actual answer** will be considered accepted.

**Example 1:**

**Input:** items = \[\[50,1\],\[10,8\]\], capacity = 5
**Output:** 55.00000
**Explanation:** 
We divide the 2nd item into two parts with part1 = 0.5 and part2 = 0.5.
The price and weight of the 1st item are 5, 4. And similarly, the price and the weight of the 2nd item are 5, 4.
The array items after operation becomes \[\[50,1\],\[5,4\],\[5,4\]\]. 
To fill a bag with capacity 5 we take the 1st element with a price of 50 and the 2nd element with a price of 5.
It can be proved that 55.0 is the maximum total price that we can achieve.

**Example 2:**

**Input:** items = \[\[100,30\]\], capacity = 50
**Output:** -1.00000
**Explanation:** It is impossible to fill a bag with the given item.

**Constraints:**

*   `1 <= items.length <= 105`
*   `items[i].length == 2`
*   `1 <= pricei, weighti <= 104`
*   `1 <= capacity <= 109`
Count Distinct Numbers on Board

You are given a positive integer `n`, that is initially placed on a board. Every day, for `109` days, you perform the following procedure:

*   For each number `x` present on the board, find all numbers `1 <= i <= n` such that `x % i == 1`.
*   Then, place those numbers on the board.

Return _the number of **distinct** integers present on the board after_ `109` _days have elapsed_.

**Note:**

*   Once a number is placed on the board, it will remain on it until the end.
*   `%` stands for the modulo operation. For example, `14 % 3` is `2`.

**Example 1:**

**Input:** n = 5
**Output:** 4
**Explanation:** Initially, 5 is present on the board. 
The next day, 2 and 4 will be added since 5 % 2 == 1 and 5 % 4 == 1. 
After that day, 3 will be added to the board because 4 % 3 == 1. 
At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5. 

**Example 2:**

**Input:** n = 3
**Output:** 2
**Explanation:** 
Since 3 % 2 == 1, 2 will be added to the board. 
After a billion days, the only two distinct numbers on the board are 2 and 3. 

**Constraints:**

*   `1 <= n <= 100`
Count Collisions of Monkeys on a Polygon

There is a regular convex polygon with `n` vertices. The vertices are labeled from `0` to `n - 1` in a clockwise direction, and each vertex has **exactly one monkey**. The following figure shows a convex polygon of `6` vertices.

Each monkey moves simultaneously to a neighboring vertex. A neighboring vertex for a vertex `i` can be:

*   the vertex `(i + 1) % n` in the clockwise direction, or
*   the vertex `(i - 1 + n) % n` in the counter-clockwise direction.

A **collision** happens if at least two monkeys reside on the same vertex after the movement or intersect on an edge.

Return _the number of ways the monkeys can move so that at least **one collision**_ _happens_. Since the answer may be very large, return it modulo `109 + 7`.

**Note** that each monkey can only move once.

**Example 1:**

**Input:** n = 3
**Output:** 6
**Explanation:** There are 8 total possible movements.
Two ways such that they collide at some point are:
- Monkey 1 moves in a clockwise direction; monkey 2 moves in an anticlockwise direction; monkey 3 moves in a clockwise direction. Monkeys 1 and 2 collide.
- Monkey 1 moves in an anticlockwise direction; monkey 2 moves in an anticlockwise direction; monkey 3 moves in a clockwise direction. Monkeys 1 and 3 collide.
It can be shown 6 total movements result in a collision.

**Example 2:**

**Input:** n = 4
**Output:** 14
**Explanation:** It can be shown that there are 14 ways for the monkeys to collide.

**Constraints:**

*   `3 <= n <= 109`
Put Marbles in Bags

You have `k` bags. You are given a **0-indexed** integer array `weights` where `weights[i]` is the weight of the `ith` marble. You are also given the integer `k.`

Divide the marbles into the `k` bags according to the following rules:

*   No bag is empty.
*   If the `ith` marble and `jth` marble are in a bag, then all marbles with an index between the `ith` and `jth` indices should also be in that same bag.
*   If a bag consists of all the marbles with an index from `i` to `j` inclusively, then the cost of the bag is `weights[i] + weights[j]`.

The **score** after distributing the marbles is the sum of the costs of all the `k` bags.

Return _the **difference** between the **maximum** and **minimum** scores among marble distributions_.

**Example 1:**

**Input:** weights = \[1,3,5,1\], k = 2
**Output:** 4
**Explanation:** 
The distribution \[1\],\[3,5,1\] results in the minimal score of (1+1) + (3+1) = 6. 
The distribution \[1,3\],\[5,1\], results in the maximal score of (1+3) + (5+1) = 10. 
Thus, we return their difference 10 - 6 = 4.

**Example 2:**

**Input:** weights = \[1, 3\], k = 2
**Output:** 0
**Explanation:** The only distribution possible is \[1\],\[3\]. 
Since both the maximal and minimal score are the same, we return 0.

**Constraints:**

*   `1 <= k <= weights.length <= 105`
*   `1 <= weights[i] <= 109`
Count Increasing Quadruplets

Given a **0-indexed** integer array `nums` of size `n` containing all numbers from `1` to `n`, return _the number of increasing quadruplets_.

A quadruplet `(i, j, k, l)` is increasing if:

*   `0 <= i < j < k < l < n`, and
*   `nums[i] < nums[k] < nums[j] < nums[l]`.

**Example 1:**

**Input:** nums = \[1,3,2,4,5\]
**Output:** 2
**Explanation:** 
- When i = 0, j = 1, k = 2, and l = 3, nums\[i\] < nums\[k\] < nums\[j\] < nums\[l\].
- When i = 0, j = 1, k = 2, and l = 4, nums\[i\] < nums\[k\] < nums\[j\] < nums\[l\]. 
There are no other quadruplets, so we return 2.

**Example 2:**

**Input:** nums = \[1,2,3,4\]
**Output:** 0
**Explanation:** There exists only one quadruplet with i = 0, j = 1, k = 2, l = 3, but since nums\[j\] < nums\[k\], we return 0.

**Constraints:**

*   `4 <= nums.length <= 4000`
*   `1 <= nums[i] <= nums.length`
*   All the integers of `nums` are **unique**. `nums` is a permutation.
Separate the Digits in an Array

Given an array of positive integers `nums`, return _an array_ `answer` _that consists of the digits of each integer in_ `nums` _after separating them in **the same order** they appear in_ `nums`.

To separate the digits of an integer is to get all the digits it has in the same order.

*   For example, for the integer `10921`, the separation of its digits is `[1,0,9,2,1]`.

**Example 1:**

**Input:** nums = \[13,25,83,77\]
**Output:** \[1,3,2,5,8,3,7,7\]
**Explanation:** 
- The separation of 13 is \[1,3\].
- The separation of 25 is \[2,5\].
- The separation of 83 is \[8,3\].
- The separation of 77 is \[7,7\].
answer = \[1,3,2,5,8,3,7,7\]. Note that answer contains the separations in the same order.

**Example 2:**

**Input:** nums = \[7,1,3,9\]
**Output:** \[7,1,3,9\]
**Explanation:** The separation of each integer in nums is itself.
answer = \[7,1,3,9\].

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `1 <= nums[i] <= 105`
Maximum Number of Integers to Choose From a Range I

You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules:

*   The chosen integers have to be in the range `[1, n]`.
*   Each integer can be chosen **at most once**.
*   The chosen integers should not be in the array `banned`.
*   The sum of the chosen integers should not exceed `maxSum`.

Return _the **maximum** number of integers you can choose following the mentioned rules_.

**Example 1:**

**Input:** banned = \[1,6,5\], n = 5, maxSum = 6
**Output:** 2
**Explanation:** You can choose the integers 2 and 4.
2 and 4 are from the range \[1, 5\], both did not appear in banned, and their sum is 6, which did not exceed maxSum.

**Example 2:**

**Input:** banned = \[1,2,3,4,5,6,7\], n = 8, maxSum = 1
**Output:** 0
**Explanation:** You cannot choose any integer while following the mentioned conditions.

**Example 3:**

**Input:** banned = \[11\], n = 7, maxSum = 50
**Output:** 7
**Explanation:** You can choose the integers 1, 2, 3, 4, 5, 6, and 7.
They are from the range \[1, 7\], all did not appear in banned, and their sum is 28, which did not exceed maxSum.

**Constraints:**

*   `1 <= banned.length <= 104`
*   `1 <= banned[i], n <= 104`
*   `1 <= maxSum <= 109`
Maximize Win From Two Segments

There are some prizes on the **X-axis**. You are given an integer array `prizePositions` that is **sorted in non-decreasing order**, where `prizePositions[i]` is the position of the `ith` prize. There could be different prizes at the same position on the line. You are also given an integer `k`.

You are allowed to select two segments with integer endpoints. The length of each segment must be `k`. You will collect all prizes whose position falls within at least one of the two selected segments (including the endpoints of the segments). The two selected segments may intersect.

*   For example if `k = 2`, you can choose segments `[1, 3]` and `[2, 4]`, and you will win any prize i that satisfies `1 <= prizePositions[i] <= 3` or `2 <= prizePositions[i] <= 4`.

Return _the **maximum** number of prizes you can win if you choose the two segments optimally_.

**Example 1:**

**Input:** prizePositions = \[1,1,2,2,3,3,5\], k = 2
**Output:** 7
**Explanation:** In this example, you can win all 7 prizes by selecting two segments \[1, 3\] and \[3, 5\].

**Example 2:**

**Input:** prizePositions = \[1,2,3,4\], k = 0
**Output:** 2
**Explanation:** For this example, **one choice** for the segments is `[3, 3]` and `[4, 4],` and you will be able to get `2` prizes. 

**Constraints:**

*   `1 <= prizePositions.length <= 105`
*   `1 <= prizePositions[i] <= 109`
*   `0 <= k <= 109`
*   `prizePositions` is sorted in non-decreasing order.

.spoilerbutton {display:block; border:dashed; padding: 0px 0px; margin:10px 0px; font-size:150%; font-weight: bold; color:#000000; background-color:cyan; outline:0; } .spoiler {overflow:hidden;} .spoiler > div {-webkit-transition: all 0s ease;-moz-transition: margin 0s ease;-o-transition: all 0s ease;transition: margin 0s ease;} .spoilerbutton\[value="Show Message"\] + .spoiler > div {margin-top:-500%;} .spoilerbutton\[value="Hide Message"\] + .spoiler {padding:5px;}
Disconnect Path in a Binary Matrix by at Most One Flip

You are given a **0-indexed** `m x n` **binary** matrix `grid`. You can move from a cell `(row, col)` to any of the cells `(row + 1, col)` or `(row, col + 1)` that has the value `1`. The matrix is **disconnected** if there is no path from `(0, 0)` to `(m - 1, n - 1)`.

You can flip the value of **at most one** (possibly none) cell. You **cannot flip** the cells `(0, 0)` and `(m - 1, n - 1)`.

Return `true` _if it is possible to make the matrix disconnect or_ `false` _otherwise_.

**Note** that flipping a cell changes its value from `0` to `1` or from `1` to `0`.

**Example 1:**

**Input:** grid = \[\[1,1,1\],\[1,0,0\],\[1,1,1\]\]
**Output:** true
**Explanation:** We can change the cell shown in the diagram above. There is no path from (0, 0) to (2, 2) in the resulting grid.

**Example 2:**

**Input:** grid = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\]
**Output:** false
**Explanation:** It is not possible to change at most one cell such that there is not path from (0, 0) to (2, 2).

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 1000`
*   `1 <= m * n <= 105`
*   `grid[i][j]` is either `0` or `1`.
*   `grid[0][0] == grid[m - 1][n - 1] == 1`
Maximum Number of Integers to Choose From a Range II

You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules:

*   The chosen integers have to be in the range `[1, n]`.
*   Each integer can be chosen **at most once**.
*   The chosen integers should not be in the array `banned`.
*   The sum of the chosen integers should not exceed `maxSum`.

Return _the **maximum** number of integers you can choose following the mentioned rules_.

**Example 1:**

**Input:** banned = \[1,4,6\], n = 6, maxSum = 4
**Output:** 1
**Explanation:** You can choose the integer 3.
3 is in the range \[1, 6\], and do not appear in banned. The sum of the chosen integers is 3, which does not exceed maxSum.

**Example 2:**

**Input:** banned = \[4,3,5,6\], n = 7, maxSum = 18
**Output:** 3
**Explanation:** You can choose the integers 1, 2, and 7.
All these integers are in the range \[1, 7\], all do not appear in banned, and their sum is 18, which does not exceed maxSum.

**Constraints:**

*   `1 <= banned.length <= 105`
*   `1 <= banned[i] <= n <= 109`
*   `1 <= maxSum <= 1015`
Take Gifts From the Richest Pile

You are given an integer array `gifts` denoting the number of gifts in various piles. Every second, you do the following:

*   Choose the pile with the maximum number of gifts.
*   If there is more than one pile with the maximum number of gifts, choose any.
*   Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts.

Return _the number of gifts remaining after_ `k` _seconds._

**Example 1:**

**Input:** gifts = \[25,64,9,4,100\], k = 4
**Output:** 29
**Explanation:** 
The gifts are taken in the following way:
- In the first second, the last pile is chosen and 10 gifts are left behind.
- Then the second pile is chosen and 8 gifts are left behind.
- After that the first pile is chosen and 5 gifts are left behind.
- Finally, the last pile is chosen again and 3 gifts are left behind.
The final remaining gifts are \[5,8,9,4,3\], so the total number of gifts remaining is 29.

**Example 2:**

**Input:** gifts = \[1,1,1,1\], k = 4
**Output:** 4
**Explanation:** 
In this case, regardless which pile you choose, you have to leave behind 1 gift in each pile. 
That is, you can't take any pile with you. 
So, the total gifts remaining are 4.

**Constraints:**

*   `1 <= gifts.length <= 103`
*   `1 <= gifts[i] <= 109`
*   `1 <= k <= 103`
Count Vowel Strings in Ranges

You are given a **0-indexed** array of strings `words` and a 2D array of integers `queries`.

Each query `queries[i] = [li, ri]` asks us to find the number of strings present in the range `li` to `ri` (both **inclusive**) of `words` that start and end with a vowel.

Return _an array_ `ans` _of size_ `queries.length`_, where_ `ans[i]` _is the answer to the_ `i`th _query_.

**Note** that the vowel letters are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.

**Example 1:**

**Input:** words = \[ "aba ", "bcb ", "ece ", "aa ", "e "\], queries = \[\[0,2\],\[1,4\],\[1,1\]\]
**Output:** \[2,3,0\]
**Explanation:** The strings starting and ending with a vowel are  "aba ",  "ece ",  "aa " and  "e ".
The answer to the query \[0,2\] is 2 (strings  "aba " and  "ece ").
to query \[1,4\] is 3 (strings  "ece ",  "aa ",  "e ").
to query \[1,1\] is 0.
We return \[2,3,0\].

**Example 2:**

**Input:** words = \[ "a ", "e ", "i "\], queries = \[\[0,2\],\[0,1\],\[2,2\]\]
**Output:** \[3,2,1\]
**Explanation:** Every string satisfies the conditions, so we return \[3,2,1\].

**Constraints:**

*   `1 <= words.length <= 105`
*   `1 <= words[i].length <= 40`
*   `words[i]` consists only of lowercase English letters.
*   `sum(words[i].length) <= 3 * 105`
*   `1 <= queries.length <= 105`
*   `0 <= li <= ri < words.length`
House Robber IV

There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he **refuses to steal from adjacent homes**.

The **capability** of the robber is the maximum amount of money he steals from one house of all the houses he robbed.

You are given an integer array `nums` representing how much money is stashed in each house. More formally, the `ith` house from the left has `nums[i]` dollars.

You are also given an integer `k`, representing the **minimum** number of houses the robber will steal from. It is always possible to steal at least `k` houses.

Return _the **minimum** capability of the robber out of all the possible ways to steal at least_ `k` _houses_.

**Example 1:**

**Input:** nums = \[2,3,5,9\], k = 2
**Output:** 5
**Explanation:** 
There are three ways to rob at least 2 houses:
- Rob the houses at indices 0 and 2. Capability is max(nums\[0\], nums\[2\]) = 5.
- Rob the houses at indices 0 and 3. Capability is max(nums\[0\], nums\[3\]) = 9.
- Rob the houses at indices 1 and 3. Capability is max(nums\[1\], nums\[3\]) = 9.
Therefore, we return min(5, 9, 9) = 5.

**Example 2:**

**Input:** nums = \[2,7,9,3,1\], k = 2
**Output:** 2
**Explanation:** There are 7 ways to rob the houses. The way which leads to minimum capability is to rob the house at index 0 and 4. Return max(nums\[0\], nums\[4\]) = 2.

**Constraints:**

*   `1 <= nums.length <= 105`
*   `1 <= nums[i] <= 109`
*   `1 <= k <= (nums.length + 1)/2`
Rearranging Fruits

You have two fruit baskets containing `n` fruits each. You are given two **0-indexed** integer arrays `basket1` and `basket2` representing the cost of fruit in each basket. You want to make both baskets **equal**. To do so, you can use the following operation as many times as you want:

*   Chose two indices `i` and `j`, and swap the `ith` fruit of `basket1` with the `jth` fruit of `basket2`.
*   The cost of the swap is `min(basket1[i],basket2[j])`.

Two baskets are considered equal if sorting them according to the fruit cost makes them exactly the same baskets.

Return _the minimum cost to make both the baskets equal or_ `-1` _if impossible._

**Example 1:**

**Input:** basket1 = \[4,2,2,2\], basket2 = \[1,4,1,2\]
**Output:** 1
**Explanation:** Swap index 1 of basket1 with index 0 of basket2, which has cost 1. Now basket1 = \[4,1,2,2\] and basket2 = \[2,4,1,2\]. Rearranging both the arrays makes them equal.

**Example 2:**

**Input:** basket1 = \[2,3,4,1\], basket2 = \[3,2,5,1\]
**Output:** -1
**Explanation:** It can be shown that it is impossible to make both the baskets equal.

**Constraints:**

*   `basket1.length == bakste2.length`
*   `1 <= basket1.length <= 105`
*   `1 <= basket1[i],basket2[i] <= 109`