bowang0911/leetcode huggingface dataset:
Minimum Cost to Buy Apples

You are given a positive integer `n` representing `n` cities numbered from `1` to `n`. You are also given a **2D** array `roads`, where `roads[i] = [ai, bi, costi]` indicates that there is a **bidirectional** road between cities `ai` and `bi` with a cost of traveling equal to `costi`.

You can buy apples in **any** city you want, but some cities have different costs to buy apples. You are given the array `appleCost` where `appleCost[i]` is the cost of buying one apple from city `i`.

You start at some city, traverse through various roads, and eventually buy **exactly** one apple from **any** city. After you buy that apple, you have to return back to the city you **started** at, but now the cost of all the roads will be **multiplied** by a given factor `k`.

Given the integer `k`, return _an array_ `answer` _of size_ `n` _where_ `answer[i]` _is the **minimum** total cost to buy an apple if you start at city_ `i`.

**Example 1:**

**Input:** n = 4, roads = \[\[1,2,4\],\[2,3,2\],\[2,4,5\],\[3,4,1\],\[1,3,4\]\], appleCost = \[56,42,102,301\], k = 2
**Output:** \[54,42,48,51\]
**Explanation:** The minimum cost for each starting city is the following:
- Starting at city 1: You take the path 1 -> 2, buy an apple at city 2, and finally take the path 2 -> 1. The total cost is 4 + 42 + 4 \* 2 = 54.
- Starting at city 2: You directly buy an apple at city 2. The total cost is 42.
- Starting at city 3: You take the path 3 -> 2, buy an apple at city 2, and finally take the path 2 -> 3. The total cost is 2 + 42 + 2 \* 2 = 48.
- Starting at city 4: You take the path 4 -> 3 -> 2 then you buy at city 2, and finally take the path 2 -> 3 -> 4. The total cost is 1 + 2 + 42 + 1 \* 2 + 2 \* 2 = 51.

**Example 2:**

**Input:** n = 3, roads = \[\[1,2,5\],\[2,3,1\],\[3,1,2\]\], appleCost = \[2,3,1\], k = 3
**Output:** \[2,3,1\]
**Explanation:** It is always optimal to buy the apple in the starting city.

**Constraints:**

*   `2 <= n <= 1000`
*   `1 <= roads.length <= 1000`
*   `1 <= ai, bi <= n`
*   `ai != bi`
*   `1 <= costi <= 105`
*   `appleCost.length == n`
*   `1 <= appleCost[i] <= 105`
*   `1 <= k <= 100`
*   There are no repeated edges.
Number of Unequal Triplets in Array

You are given a **0-indexed** array of positive integers `nums`. Find the number of triplets `(i, j, k)` that meet the following conditions:

*   `0 <= i < j < k < nums.length`
*   `nums[i]`, `nums[j]`, and `nums[k]` are **pairwise distinct**.
    *   In other words, `nums[i] != nums[j]`, `nums[i] != nums[k]`, and `nums[j] != nums[k]`.

Return _the number of triplets that meet the conditions._

**Example 1:**

**Input:** nums = \[4,4,2,4,3\]
**Output:** 3
**Explanation:** The following triplets meet the conditions:
- (0, 2, 4) because 4 != 2 != 3
- (1, 2, 4) because 4 != 2 != 3
- (2, 3, 4) because 2 != 4 != 3
Since there are 3 triplets, we return 3.
Note that (2, 0, 4) is not a valid triplet because 2 > 0.

**Example 2:**

**Input:** nums = \[1,1,1,1,1\]
**Output:** 0
**Explanation:** No triplets meet the conditions so we return 0.

**Constraints:**

*   `3 <= nums.length <= 100`
*   `1 <= nums[i] <= 1000`
Closest Nodes Queries in a Binary Search Tree

You are given the `root` of a **binary search tree** and an array `queries` of size `n` consisting of positive integers.

Find a **2D** array `answer` of size `n` where `answer[i] = [mini, maxi]`:

*   `mini` is the **largest** value in the tree that is smaller than or equal to `queries[i]`. If a such value does not exist, add `-1` instead.
*   `maxi` is the **smallest** value in the tree that is greater than or equal to `queries[i]`. If a such value does not exist, add `-1` instead.

Return _the array_ `answer`.

**Example 1:**

**Input:** root = \[6,2,13,1,4,9,15,null,null,null,null,null,null,14\], queries = \[2,5,16\]
**Output:** \[\[2,2\],\[4,6\],\[15,-1\]\]
**Explanation:** We answer the queries in the following way:
- The largest number that is smaller or equal than 2 in the tree is 2, and the smallest number that is greater or equal than 2 is still 2. So the answer for the first query is \[2,2\].
- The largest number that is smaller or equal than 5 in the tree is 4, and the smallest number that is greater or equal than 5 is 6. So the answer for the second query is \[4,6\].
- The largest number that is smaller or equal than 16 in the tree is 15, and the smallest number that is greater or equal than 16 does not exist. So the answer for the third query is \[15,-1\].

**Example 2:**

**Input:** root = \[4,null,9\], queries = \[3\]
**Output:** \[\[-1,4\]\]
**Explanation:** The largest number that is smaller or equal to 3 in the tree does not exist, and the smallest number that is greater or equal to 3 is 4. So the answer for the query is \[-1,4\].

**Constraints:**

*   The number of nodes in the tree is in the range `[2, 105]`.
*   `1 <= Node.val <= 106`
*   `n == queries.length`
*   `1 <= n <= 105`
*   `1 <= queries[i] <= 106`
Minimum Fuel Cost to Report to the Capital

There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of `n` cities numbered from `0` to `n - 1` and exactly `n - 1` roads. The capital city is city `0`. You are given a 2D integer array `roads` where `roads[i] = [ai, bi]` denotes that there exists a **bidirectional road** connecting cities `ai` and `bi`.

There is a meeting for the representatives of each city. The meeting is in the capital city.

There is a car in each city. You are given an integer `seats` that indicates the number of seats in each car.

A representative can use the car in their city to travel or change the car and ride with another representative. The cost of traveling between two cities is one liter of fuel.

Return _the minimum number of liters of fuel to reach the capital city_.

**Example 1:**

**Input:** roads = \[\[0,1\],\[0,2\],\[0,3\]\], seats = 5
**Output:** 3
**Explanation:** 
- Representative1 goes directly to the capital with 1 liter of fuel.
- Representative2 goes directly to the capital with 1 liter of fuel.
- Representative3 goes directly to the capital with 1 liter of fuel.
It costs 3 liters of fuel at minimum. 
It can be proven that 3 is the minimum number of liters of fuel needed.

**Example 2:**

**Input:** roads = \[\[3,1\],\[3,2\],\[1,0\],\[0,4\],\[0,5\],\[4,6\]\], seats = 2
**Output:** 7
**Explanation:** 
- Representative2 goes directly to city 3 with 1 liter of fuel.
- Representative2 and representative3 go together to city 1 with 1 liter of fuel.
- Representative2 and representative3 go together to the capital with 1 liter of fuel.
- Representative1 goes directly to the capital with 1 liter of fuel.
- Representative5 goes directly to the capital with 1 liter of fuel.
- Representative6 goes directly to city 4 with 1 liter of fuel.
- Representative4 and representative6 go together to the capital with 1 liter of fuel.
It costs 7 liters of fuel at minimum. 
It can be proven that 7 is the minimum number of liters of fuel needed.

**Example 3:**

**Input:** roads = \[\], seats = 1
**Output:** 0
**Explanation:** No representatives need to travel to the capital city.

**Constraints:**

*   `1 <= n <= 105`
*   `roads.length == n - 1`
*   `roads[i].length == 2`
*   `0 <= ai, bi < n`
*   `ai != bi`
*   `roads` represents a valid tree.
*   `1 <= seats <= 105`
Number of Beautiful Partitions

You are given a string `s` that consists of the digits `'1'` to `'9'` and two integers `k` and `minLength`.

A partition of `s` is called **beautiful** if:

*   `s` is partitioned into `k` non-intersecting substrings.
*   Each substring has a length of **at least** `minLength`.
*   Each substring starts with a **prime** digit and ends with a **non-prime** digit. Prime digits are `'2'`, `'3'`, `'5'`, and `'7'`, and the rest of the digits are non-prime.

Return _the number of **beautiful** partitions of_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`.

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

**Example 1:**

**Input:** s =  "23542185131 ", k = 3, minLength = 2
**Output:** 3
**Explanation:** There exists three ways to create a beautiful partition:
 "2354 | 218 | 5131 "
 "2354 | 21851 | 31 "
 "2354218 | 51 | 31 "

**Example 2:**

**Input:** s =  "23542185131 ", k = 3, minLength = 3
**Output:** 1
**Explanation:** There exists one way to create a beautiful partition:  "2354 | 218 | 5131 ".

**Example 3:**

**Input:** s =  "3312958 ", k = 3, minLength = 1
**Output:** 1
**Explanation:** There exists one way to create a beautiful partition:  "331 | 29 | 58 ".

**Constraints:**

*   `1 <= k, minLength <= s.length <= 1000`
*   `s` consists of the digits `'1'` to `'9'`.
Maximum XOR of Two Non-Overlapping Subtrees

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

Each node has an associated **value**. You are given an array `values` of length `n`, where `values[i]` is the **value** of the `ith` node.

Select any two **non-overlapping** subtrees. Your **score** is the bitwise XOR of the sum of the values within those subtrees.

Return _the_ _**maximum**_ _possible **score** you can achieve_. _If it is impossible to find two nonoverlapping subtrees_, return `0`.

**Note** that:

*   The **subtree** of a node is the tree consisting of that node and all of its descendants.
*   Two subtrees are **non-overlapping** if they do not share **any common** node.

**Example 1:**

**Input:** n = 6, edges = \[\[0,1\],\[0,2\],\[1,3\],\[1,4\],\[2,5\]\], values = \[2,8,3,6,2,5\]
**Output:** 24
**Explanation:** Node 1's subtree has sum of values 16, while node 2's subtree has sum of values 8, so choosing these nodes will yield a score of 16 XOR 8 = 24. It can be proved that is the maximum possible score we can obtain.

**Example 2:**

**Input:** n = 3, edges = \[\[0,1\],\[1,2\]\], values = \[4,6,1\]
**Output:** 0
**Explanation:** There is no possible way to select two non-overlapping subtrees, so we just return 0.

**Constraints:**

*   `2 <= n <= 5 * 104`
*   `edges.length == n - 1`
*   `0 <= ai, bi < n`
*   `values.length == n`
*   `1 <= values[i] <= 109`
*   It is guaranteed that `edges` represents a valid tree.
Minimum Cuts to Divide a Circle

A **valid cut** in a circle can be:

*   A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or
*   A cut that is represented by a straight line that touches one point on the edge of the circle and its center.

Some valid and invalid cuts are shown in the figures below.

Given the integer `n`, return _the **minimum** number of cuts needed to divide a circle into_ `n` _equal slices_.

**Example 1:**

**Input:** n = 4
**Output:** 2
**Explanation:** 
The above figure shows how cutting the circle twice through the middle divides it into 4 equal slices.

**Example 2:**

**Input:** n = 3
**Output:** 3
**Explanation:**
At least 3 cuts are needed to divide the circle into 3 equal slices. 
It can be shown that less than 3 cuts cannot result in 3 slices of equal size and shape.
Also note that the first cut will not divide the circle into distinct parts.

**Constraints:**

*   `1 <= n <= 100`
Difference Between Ones and Zeros in Row and Column

You are given a **0-indexed** `m x n` binary matrix `grid`.

A **0-indexed** `m x n` difference matrix `diff` is created with the following procedure:

*   Let the number of ones in the `ith` row be `onesRowi`.
*   Let the number of ones in the `jth` column be `onesColj`.
*   Let the number of zeros in the `ith` row be `zerosRowi`.
*   Let the number of zeros in the `jth` column be `zerosColj`.
*   `diff[i][j] = onesRowi + onesColj - zerosRowi - zerosColj`

Return _the difference matrix_ `diff`.

**Example 1:**

**Input:** grid = \[\[0,1,1\],\[1,0,1\],\[0,0,1\]\]
**Output:** \[\[0,0,4\],\[0,0,4\],\[-2,-2,2\]\]
**Explanation:**
- diff\[0\]\[0\] = `onesRow0 + onesCol0 - zerosRow0 - zerosCol0` = 2 + 1 - 1 - 2 = 0 
- diff\[0\]\[1\] = `onesRow0 + onesCol1 - zerosRow0 - zerosCol1` = 2 + 1 - 1 - 2 = 0 
- diff\[0\]\[2\] = `onesRow0 + onesCol2 - zerosRow0 - zerosCol2` = 2 + 3 - 1 - 0 = 4 
- diff\[1\]\[0\] = `onesRow1 + onesCol0 - zerosRow1 - zerosCol0` = 2 + 1 - 1 - 2 = 0 
- diff\[1\]\[1\] = `onesRow1 + onesCol1 - zerosRow1 - zerosCol1` = 2 + 1 - 1 - 2 = 0 
- diff\[1\]\[2\] = `onesRow1 + onesCol2 - zerosRow1 - zerosCol2` = 2 + 3 - 1 - 0 = 4 
- diff\[2\]\[0\] = `onesRow2 + onesCol0 - zerosRow2 - zerosCol0` = 1 + 1 - 2 - 2 = -2
- diff\[2\]\[1\] = `onesRow2 + onesCol1 - zerosRow2 - zerosCol1` = 1 + 1 - 2 - 2 = -2
- diff\[2\]\[2\] = `onesRow2 + onesCol2 - zerosRow2 - zerosCol2` = 1 + 3 - 2 - 0 = 2

**Example 2:**

**Input:** grid = \[\[1,1,1\],\[1,1,1\]\]
**Output:** \[\[5,5,5\],\[5,5,5\]\]
**Explanation:**
- diff\[0\]\[0\] = onesRow0 + onesCol0 - zerosRow0 - zerosCol0 = 3 + 2 - 0 - 0 = 5
- diff\[0\]\[1\] = onesRow0 + onesCol1 - zerosRow0 - zerosCol1 = 3 + 2 - 0 - 0 = 5
- diff\[0\]\[2\] = onesRow0 + onesCol2 - zerosRow0 - zerosCol2 = 3 + 2 - 0 - 0 = 5
- diff\[1\]\[0\] = onesRow1 + onesCol0 - zerosRow1 - zerosCol0 = 3 + 2 - 0 - 0 = 5
- diff\[1\]\[1\] = onesRow1 + onesCol1 - zerosRow1 - zerosCol1 = 3 + 2 - 0 - 0 = 5
- diff\[1\]\[2\] = onesRow1 + onesCol2 - zerosRow1 - zerosCol2 = 3 + 2 - 0 - 0 = 5

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 105`
*   `1 <= m * n <= 105`
*   `grid[i][j]` is either `0` or `1`.
Minimum Penalty for a Shop

You are given the customer visit log of a shop represented by a **0-indexed** string `customers` consisting only of characters `'N'` and `'Y'`:

*   if the `ith` character is `'Y'`, it means that customers come at the `ith` hour
*   whereas `'N'` indicates that no customers come at the `ith` hour.

If the shop closes at the `jth` hour (`0 <= j <= n`), the **penalty** is calculated as follows:

*   For every hour when the shop is open and no customers come, the penalty increases by `1`.
*   For every hour when the shop is closed and customers come, the penalty increases by `1`.

Return _the **earliest** hour at which the shop must be closed to incur a **minimum** penalty._

**Note** that if a shop closes at the `jth` hour, it means the shop is closed at the hour `j`.

**Example 1:**

**Input:** customers =  "YYNY "
**Output:** 2
**Explanation:** 
- Closing the shop at the 0th hour incurs in 1+1+0+1 = 3 penalty.
- Closing the shop at the 1st hour incurs in 0+1+0+1 = 2 penalty.
- Closing the shop at the 2nd hour incurs in 0+0+0+1 = 1 penalty.
- Closing the shop at the 3rd hour incurs in 0+0+1+1 = 2 penalty.
- Closing the shop at the 4th hour incurs in 0+0+1+0 = 1 penalty.
Closing the shop at 2nd or 4th hour gives a minimum penalty. Since 2 is earlier, the optimal closing time is 2.

**Example 2:**

**Input:** customers =  "NNNNN "
**Output:** 0
**Explanation:** It is best to close the shop at the 0th hour as no customers arrive.

**Example 3:**

**Input:** customers =  "YYYY "
**Output:** 4
**Explanation:** It is best to close the shop at the 4th hour as customers arrive at each hour.

**Constraints:**

*   `1 <= customers.length <= 105`
*   `customers` consists only of characters `'Y'` and `'N'`.
Count Palindromic Subsequences

Given a string of digits `s`, return _the number of **palindromic subsequences** of_ `s` _having length_ `5`. Since the answer may be very large, return it **modulo** `109 + 7`.

**Note:**

*   A string is **palindromic** if it reads the same forward and backward.
*   A **subsequence** is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

**Example 1:**

**Input:** s =  "103301 "
**Output:** 2
**Explanation:** 
There are 6 possible subsequences of length 5:  "10330 ", "10331 ", "10301 ", "10301 ", "13301 ", "03301 ". 
Two of them (both equal to  "10301 ") are palindromic.

**Example 2:**

**Input:** s =  "0000000 "
**Output:** 21
**Explanation:** All 21 subsequences are  "00000 ", which is palindromic.

**Example 3:**

**Input:** s =  "9999900000 "
**Output:** 2
**Explanation:** The only two palindromic subsequences are  "99999 " and  "00000 ".

**Constraints:**

*   `1 <= s.length <= 104`
*   `s` consists of digits.
Find the Pivot Integer

Given a positive integer `n`, find the **pivot integer** `x` such that:

*   The sum of all elements between `1` and `x` inclusively equals the sum of all elements between `x` and `n` inclusively.

Return _the pivot integer_ `x`. If no such integer exists, return `-1`. It is guaranteed that there will be at most one pivot index for the given input.

**Example 1:**

**Input:** n = 8
**Output:** 6
**Explanation:** 6 is the pivot integer since: 1 + 2 + 3 + 4 + 5 + 6 = 6 + 7 + 8 = 21.

**Example 2:**

**Input:** n = 1
**Output:** 1
**Explanation:** 1 is the pivot integer since: 1 = 1.

**Example 3:**

**Input:** n = 4
**Output:** -1
**Explanation:** It can be proved that no such integer exist.

**Constraints:**

*   `1 <= n <= 1000`
Append Characters to String to Make Subsequence

You are given two strings `s` and `t` consisting of only lowercase English letters.

Return _the minimum number of characters that need to be appended to the end of_ `s` _so that_ `t` _becomes a **subsequence** of_ `s`.

A **subsequence** is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

**Example 1:**

**Input:** s =  "coaching ", t =  "coding "
**Output:** 4
**Explanation:** Append the characters  "ding " to the end of s so that s =  "coachingding ".
Now, t is a subsequence of s ( "**co**aching**ding** ").
It can be shown that appending any 3 characters to the end of s will never make t a subsequence.

**Example 2:**

**Input:** s =  "abcde ", t =  "a "
**Output:** 0
**Explanation:** t is already a subsequence of s ( "**a**bcde ").

**Example 3:**

**Input:** s =  "z ", t =  "abcde "
**Output:** 5
**Explanation:** Append the characters  "abcde " to the end of s so that s =  "zabcde ".
Now, t is a subsequence of s ( "z**abcde** ").
It can be shown that appending any 4 characters to the end of s will never make t a subsequence.

**Constraints:**

*   `1 <= s.length, t.length <= 105`
*   `s` and `t` consist only of lowercase English letters.
Remove Nodes From Linked List

You are given the `head` of a linked list.

Remove every node which has a node with a **strictly greater** value anywhere to the right side of it.

Return _the_ `head` _of the modified linked list._

**Example 1:**

**Input:** head = \[5,2,13,3,8\]
**Output:** \[13,8\]
**Explanation:** The nodes that should be removed are 5, 2 and 3.
- Node 13 is to the right of node 5.
- Node 13 is to the right of node 2.
- Node 8 is to the right of node 3.

**Example 2:**

**Input:** head = \[1,1,1,1\]
**Output:** \[1,1,1,1\]
**Explanation:** Every node has value 1, so no nodes are removed.

**Constraints:**

*   The number of the nodes in the given list is in the range `[1, 105]`.
*   `1 <= Node.val <= 105`
Count Subarrays With Median K

You are given an array `nums` of size `n` consisting of **distinct** integers from `1` to `n` and a positive integer `k`.

Return _the number of non-empty subarrays in_ `nums` _that have a **median** equal to_ `k`.

**Note**:

*   The median of an array is the **middle** element after sorting the array in **ascending** order. If the array is of even length, the median is the **left** middle element.
    *   For example, the median of `[2,3,1,4]` is `2`, and the median of `[8,4,3,5,1]` is `4`.
*   A subarray is a contiguous part of an array.

**Example 1:**

**Input:** nums = \[3,2,1,4,5\], k = 4
**Output:** 3
**Explanation:** The subarrays that have a median equal to 4 are: \[4\], \[4,5\] and \[1,4,5\].

**Example 2:**

**Input:** nums = \[2,3,1\], k = 3
**Output:** 1
**Explanation:** \[3\] is the only subarray that has a median equal to 3.

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 105`
*   `1 <= nums[i], k <= n`
*   The integers in `nums` are distinct.
Number of Substrings With Fixed Ratio

You are given a binary string `s`, and two integers `num1` and `num2`. `num1` and `num2` are coprime numbers.

A **ratio substring** is a substring of s where the ratio between the number of `0`'s and the number of `1`'s in the substring is exactly `num1 : num2`.

*   For example, if `num1 = 2` and `num2 = 3`, then `"01011 "` and `"1110000111 "` are ratio substrings, while `"11000 "` is not.

Return _the number of **non-empty** ratio substrings of_ `s`.

**Note** that:

*   A **substring** is a contiguous sequence of characters within a string.
*   Two values `x` and `y` are **coprime** if `gcd(x, y) == 1` where `gcd(x, y)` is the greatest common divisor of `x` and `y`.

**Example 1:**

**Input:** s =  "0110011 ", num1 = 1, num2 = 2
**Output:** 4
**Explanation:** There exist 4 non-empty ratio substrings.
- The substring s\[0..2\]:  "0110011 ". It contains one 0 and two 1's. The ratio is 1 : 2.
- The substring s\[1..4\]:  "0110011 ". It contains one 0 and two 1's. The ratio is 1 : 2.
- The substring s\[4..6\]:  "0110011 ". It contains one 0 and two 1's. The ratio is 1 : 2.
- The substring s\[1..6\]:  "0110011 ". It contains two 0's and four 1's. The ratio is 2 : 4 == 1 : 2.
It can be shown that there are no more ratio substrings.

**Example 2:**

**Input:** s =  "10101 ", num1 = 3, num2 = 1
**Output:** 0
**Explanation:** There is no ratio substrings of s. We return 0.

**Constraints:**

*   `1 <= s.length <= 105`
*   `1 <= num1, num2 <= s.length`
*   `num1` and `num2` are coprime integers.
Circular Sentence

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. Uppercase and lowercase English letters are considered different.

A sentence is **circular** if:

*   The last character of a word is equal to the first character of the next word.
*   The last character of the last word is equal to the first character of the first word.

For example, `"leetcode exercises sound delightful "`, `"eetcode "`, `"leetcode eats soul "` are all circular sentences. However, `"Leetcode is cool "`, `"happy Leetcode "`, `"Leetcode "` and `"I like Leetcode "` are **not** circular sentences.

Given a string `sentence`, return `true` _if it is circular_. Otherwise, return `false`.

**Example 1:**

**Input:** sentence =  "leetcode exercises sound delightful "
**Output:** true
**Explanation:** The words in sentence are \[ "leetcode ",  "exercises ",  "sound ",  "delightful "\].
- leetcode's last character is equal to exercises's first character.
- exercises's last character is equal to sound's first character.
- sound's last character is equal to delightful's first character.
- delightful's last character is equal to leetcode's first character.
The sentence is circular.

**Example 2:**

**Input:** sentence =  "eetcode "
**Output:** true
**Explanation:** The words in sentence are \[ "eetcode "\].
- eetcode's last character is equal to eetcode's first character.
The sentence is circular.

**Example 3:**

**Input:** sentence =  "Leetcode is cool "
**Output:** false
**Explanation:** The words in sentence are \[ "Leetcode ",  "is ",  "cool "\].
- Leetcode's last character is **not** equal to is's first character.
The sentence is **not** circular.

**Constraints:**

*   `1 <= sentence.length <= 500`
*   `sentence` consist of only lowercase and uppercase English letters and spaces.
*   The words in `sentence` are separated by a single space.
*   There are no leading or trailing spaces.