You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
We call an array arr of length n consecutive if one of the following holds:

arr[i] - arr[i - 1] == 1 for all 1 <= i < n.
arr[i] - arr[i - 1] == -1 for all 1 <= i < n.

The value of an array is the sum of its elements.
For example, [3, 4, 5] is a consecutive array of value 12 and [9, 8] is another of value 17. While [3, 4, 3] and [8, 6] are not consecutive.
Given an array of integers nums, return the sum of the values of all consecutive non-empty subsequences.
Since the answer may be very large, return it modulo 109 + 7.
Note that an array of length 1 is also considered consecutive.

Example 1:

Input: nums = [1,2]
Output: 6
Explanation:
The consecutive subsequences are: [1], [2], [1, 2].

Example 2:

Input: nums = [1,4,2,3]
Output: 31
Explanation:
The consecutive subsequences are: [1], [4], [2], [3], [1, 2], [2, 3], [4, 3], [1, 2, 3].

Constraints:

1 <= nums.length <= 105
1 <= nums[i] <= 105

Your solution to the problem should be a method of the class Solution called getSum and should pass all tests. Use the following starter code:
```python
class Solution:
    def getSum(self, nums: List[int]) -> int:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
We call an array arr of length n consecutive if one of the following holds:

arr[i] - arr[i - 1] == 1 for all 1 <= i < n.
arr[i] - arr[i - 1] == -1 for all 1 <= i < n.

The value of an array is the sum of its elements.
For example, [3, 4, 5] is a consecutive array of value 12 and [9, 8] is another of value 17. While [3, 4, 3] and [8, 6] are not consecutive.
Given an array of integers nums, return the sum of the values of all consecutive non-empty subsequences.
Since the answer may be very large, return it modulo 109 + 7.
Note that an array of length 1 is also considered consecutive.

Example 1:

Input: nums = [1,2]
Output: 6
Explanation:
The consecutive subsequences are: [1], [2], [1, 2].

Example 2:

Input: nums = [1,4,2,3]
Output: 31
Explanation:
The consecutive subsequences are: [1], [4], [2], [3], [1, 2], [2, 3], [4, 3], [1, 2, 3].

Constraints:

1 <= nums.length <= 105
1 <= nums[i] <= 105

Your solution to the problem should be a method of the class Solution called getSum and should pass all tests. Use the following starter code:
```python
class Solution:
    def getSum(self, nums: List[int]) -> int:
        # Add your code here
```

SOLUTION:

assert Solution().getSum(nums = [1,3,5,7,9]) == 25

assert Solution().getSum(nums = [8,6]) == 14

assert Solution().getSum(nums = [1,4,2,3]) == 31

assert Solution().getSum(nums = [1]) == 1

assert Solution().getSum(nums = [3,4,5]) == 40

assert Solution().getSum(nums = [1,2,3,4,5]) == 105

assert Solution().getSum(nums = [10,9,8,7,6]) == 280

assert Solution().getSum(nums = [1,1,1,1,1]) == 5

assert Solution().getSum(nums = [9,8]) == 34

assert Solution().getSum(nums = [5,4,3,2,1]) == 105

assert Solution().getSum(nums = [100000]) == 100000

assert Solution().getSum(nums = [3,4,3]) == 24

assert Solution().getSum(nums = [1,2]) == 6

assert Solution().getSum(nums = [5]) == 5

assert Solution().getSum(nums = [2,2,2,2,2]) == 10

Answer: assert Solution().getSum(nums = [1,3,2,4,3,5,4,6,5,7]) == 352

Answer: assert Solution().getSum(nums = [100000, 99999, 99998, 99997, 99996]) == 3499930

Answer: assert Solution().getSum(nums = [2,2,2,2,2,2,2,2,2,2]) == 20

Answer: assert Solution().getSum(nums = [1,2,4,3,5,6,7,8,10,9,11,12]) == 520

Answer: assert Solution().getSum(nums = [1,3,5,7,9]) == 25

Answer: assert Solution().getSum(nums = [8,6]) == 14

Answer: assert Solution().getSum(nums = [1,4,2,3]) == 31

Answer: assert Solution().getSum(nums = [1]) == 1

Answer: assert Solution().getSum(nums = [1,2,4,5,6,8,9,10]) == 146

Answer: assert Solution().getSum(nums = [3,4,5]) == 40

Answer: assert Solution().getSum(nums = [1,2,3,4,5]) == 105

Answer: assert Solution().getSum(nums = [10,9,8,7,6]) == 280

Answer: assert Solution().getSum(nums = [1,2,3,5,6,7,8,10]) == 160

Answer: assert Solution().getSum(nums = [1,1,1,1,1]) == 5

Answer: assert Solution().getSum(nums = [9,8]) == 34

Answer: assert Solution().getSum(nums = [1,3,2,4,3,5,4,6,5]) == 267

Answer: assert Solution().getSum(nums = [5,4,3,2,1]) == 105

Answer: assert Solution().getSum(nums = [100000]) == 100000

Answer: assert Solution().getSum(nums = [3,4,3]) == 24

Answer: assert Solution().getSum(nums = [1,2]) == 6

Answer: assert Solution().getSum(nums = [5]) == 5

Answer: assert Solution().getSum(nums = [2,2,2,2,2]) == 10

Answer: assert Solution().getSum(nums = [100000,99999,99998,99997,99996]) == 3499930

Answer: assert Solution().getSum(nums = [1,2,3,4,3,4,5,4,5,6,5,6,7,6,7,8,7,8,9,8,9,10]) == 183823

Answer: assert Solution().getSum(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 30030

Answer: assert Solution().getSum(nums = [100, 101, 102, 100, 101, 102, 103, 104]) == 10688

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10]) == 1210

Answer: assert Solution().getSum(nums = [10,20,19,18,17,16,15,14,13,12,11]) == 3441

Answer: assert Solution().getSum(nums = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]) == 91

Answer: assert Solution().getSum(nums = [5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]) == 22330

Answer: assert Solution().getSum(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16170

Answer: assert Solution().getSum(nums = [10,9,8,7,6,5,4,3,2,1,1,2,3,4,5]) == 2320

Answer: assert Solution().getSum(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35]) == 324

Answer: assert Solution().getSum(nums = [5,6,7,8,7,8,9,10,11,12,13,14,15,16,17]) == 10053

Answer: assert Solution().getSum(nums = [1, 3, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15]) == 461

Answer: assert Solution().getSum(nums = [1,2,3,2,3,4,5,4,5,6,7,8,7,8,9,10]) == 14564

Answer: assert Solution().getSum(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 11, 13, 12]) == 397

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 1233

Answer: assert Solution().getSum(nums = [1,2,3,5,6,7,9,10,11,13,14,15]) == 320

Answer: assert Solution().getSum(nums = [1,2,3,1,2,3,1,2,3,1,2,3]) == 296

Answer: assert Solution().getSum(nums = [1, 2, 3, 2, 1, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 1344

Answer: assert Solution().getSum(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 225

Answer: assert Solution().getSum(nums = [10,11,12,13,14,15,16,17,18,19,20,18,17,16,15,14,13,12,11,10]) == 11829

Answer: assert Solution().getSum(nums = [2,1,3,4,5,6,7,8,9,10]) == 994

Answer: assert Solution().getSum(nums = [1,2,3,4,5,4,3,2,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]) == 12653

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]) == 3970

Answer: assert Solution().getSum(nums = [1,3,2,4,3,2,1,2,3,4,5,4,3,2,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5]) == 28617

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]) == 76880

Answer: assert Solution().getSum(nums = [2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1]) == 330

Answer: assert Solution().getSum(nums = [100,99,98,97,96,95,94,93,92,91]) == 21010

Answer: assert Solution().getSum(nums = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]) == 900

Answer: assert Solution().getSum(nums = [100000,99999,99998,99997,99996,99995,99994,99993,99992,99991]) == 21999010

Answer: assert Solution().getSum(nums = [2, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2]) == 789

Answer: assert Solution().getSum(nums = [2,3,1,2,3,4,5,3,4,5,6,7,5,6,7,8,9,10,8,9,10,11,12]) == 105309

Answer: assert Solution().getSum(nums = [5,6,7,8,9,10,11,12,13,14,15,5,6,7,8,9,10,11,12,13,14,15]) == 20220

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10]) == 17402

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) == 5440

Answer: assert Solution().getSum(nums = [50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]) == 106260

Answer: assert Solution().getSum(nums = [1,3,2,4,3,5,6,7,8,9,10,8,7,6,5,4,3,2,1]) == 2483

Answer: assert Solution().getSum(nums = [7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8]) == 3150

Answer: assert Solution().getSum(nums = [1,2,3,5,4,3,2,1,2,3,4,5,6,7,8,9,10,8,7,6,5,4,3,2,1]) == 8381

Answer: assert Solution().getSum(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 852

Answer: assert Solution().getSum(nums = [10,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]) == 16576

Answer: assert Solution().getSum(nums = [1,3,5,7,9,11,13,15,17,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]) == 18316

Answer: assert Solution().getSum(nums = [1,3,2,4,3,5,4,6,5,7,6,8,7,9,8]) == 1891

Answer: assert Solution().getSum(nums = [9,8,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10]) == 3586

Answer: assert Solution().getSum(nums = [10,20,30,40,50,60,70,80,90,100,110]) == 660

Answer: assert Solution().getSum(nums = [1,2,1,3,2,4,3,5,4,6,5,7,6,8,7,9,8,10]) == 3720

Answer: assert Solution().getSum(nums = [1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10]) == 110

Answer: assert Solution().getSum(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15

Answer: assert Solution().getSum(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 21999010

Answer: assert Solution().getSum(nums = [1,2,1,2,1,2,1,2,1,2,1,2]) == 126

Answer: assert Solution().getSum(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4291

Answer: assert Solution().getSum(nums = [5,6,7,8,9,10,11,12,13,14,15]) == 2860

Answer: assert Solution().getSum(nums = [1, 2, 3, 5, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19]) == 1481

Answer: assert Solution().getSum(nums = [1,3,5,7,9,11,13,15,17,19]) == 100

Answer: assert Solution().getSum(nums = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]) == 15

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 11, 12, 13, 14]) == 148444

Answer: assert Solution().getSum(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16

Answer: assert Solution().getSum(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8]) == 1387

Answer: assert Solution().getSum(nums = [100,101,102,103,104,105,106,107,108,109,110]) == 30030

Answer: assert Solution().getSum(nums = [5,6,7,8,9,1,2,3,4,10,11,12,13,14,15,16]) == 3881

Answer: assert Solution().getSum(nums = [1,2,3,5,6,7,8,10,11,12,14,15,16]) == 410

Answer: assert Solution().getSum(nums = [100,101,102,103,104,105,106,107,108,109]) == 22990

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]) == 16170

Answer: assert Solution().getSum(nums = [2,3,5,6,8,9,11,12,14,15,17,18,20,21]) == 322

Answer: assert Solution().getSum(nums = [5,4,3,2,1,2,3,4,5,4,3,2,1,2,3,4,5,4,3,2,1,2,3,4,5,4,3,2,1]) == 9630

Answer: assert Solution().getSum(nums = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 22000990

Answer: assert Solution().getSum(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992]) == 16499340

Answer: assert Solution().getSum(nums = [1, 2, 3, 5, 6, 7, 10, 11, 12, 15, 16, 17, 18, 19]) == 785

Answer: assert Solution().getSum(nums = [1,2,3,4,5,3,4,5,6,7,8,6,7,8,9,10,11,9,10,11,12]) == 64196

Answer: assert Solution().getSum(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2764

Answer: assert Solution().getSum(nums = [10,9,8,7,6,5,4,3,2,1]) == 1210

Answer: assert Solution().getSum(nums = [1,2,2,3,4,4,5,6,6,7,8,8,9,10,10]) == 11871

Answer: assert Solution().getSum(nums = [1, 2, 3, 5, 4, 3, 2, 1, 0, -1, -2, -3]) == 249

Answer: assert Solution().getSum(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 10056

Answer: assert Solution().getSum(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1210

Answer: assert Solution().getSum(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100

Answer: assert Solution().getSum(nums = [1,2,3,4,5,4,3,2,1,2,3,4,5,6,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10]) == 42414

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]) == 42920

Answer: assert Solution().getSum(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 121

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]) == 38025

Answer: assert Solution().getSum(nums = [1,2,3,4,5,7,8,9,10,12,13,14,15,17,18,19]) == 725

Answer: assert Solution().getSum(nums = [20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,20,19,18,17,16,15]) == 19804

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5440

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1210

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]) == 154792

Answer: assert Solution().getSum(nums = [1,3,2,4,6,5,7,9,8,10]) == 187

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10]) == 33462

Answer: assert Solution().getSum(nums = [1,2,2,3,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10]) == 190870

Answer: assert Solution().getSum(nums = [5,4,3,2,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) == 8036

Answer: assert Solution().getSum(nums = [1,2,3,4,5,4,3,2,1,2,3,4,5,4,3,2,1]) == 1603

Answer: assert Solution().getSum(nums = [1,3,5,7,9,11,13,15,17,19,21,23,25]) == 169

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16170

Answer: assert Solution().getSum(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 2402

Answer: assert Solution().getSum(nums = [5,4,3,2,1,2,3,4,5,6,7,8,9,10]) == 2066

Answer: assert Solution().getSum(nums = [1,2,3,4,3,4,5,6,5,6,7,8,7,8,9,10]) == 17666

Answer: assert Solution().getSum(nums = [1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]) == 61409

Answer: assert Solution().getSum(nums = [10,9,8,7,6,5,4,3,2,1,1,2,3,4,5,6,7,8,9,10]) == 4730

Answer: assert Solution().getSum(nums = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10]) == 7964

Answer: assert Solution().getSum(nums = [1,3,2,4,3,5,4,6,5,7,6,8,5,9]) == 1008

Answer: assert Solution().getSum(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 2040

Answer: assert Solution().getSum(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 1944

Answer: assert Solution().getSum(nums = [5,6,7,8,9,5,4,3,2,1,5,6,7,8,9]) == 1481

Answer: assert Solution().getSum(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 21998790

Answer: assert Solution().getSum(nums = [1,2,3,4,5,3,2,1,2,3,4,5,6,7,8,9,10]) == 5259

Answer: assert Solution().getSum(nums = [10,9,8,7,6,5,3,4,2,1,3,2,4,5,7,6,8,9]) == 2105

Answer: assert Solution().getSum(nums = [10,9,8,7,6,5,4,3,2,1,10,9,8,7,6,5,4,3,2,1,10,9,8,7,6,5,4,3,2,1]) == 33462

Answer: assert Solution().getSum(nums = [1,1,1,1,1,1,1,1,1,1]) == 10

Answer: assert Solution().getSum(nums = [2,4,6,8,10,12,14,16,18,20]) == 110

Answer: assert Solution().getSum(nums = [100,101,102,103,104,105,106,107,108,109,110,111,112,113,114]) == 72760

Answer: assert Solution().getSum(nums = [100000,99999,99998,99997,99996,99995]) == 5599860

Answer: assert Solution().getSum(nums = [1,3,2,4,5,7,6,8,9,10,12,11,13,14,15]) == 722

Answer: assert Solution().getSum(nums = [1,2,3,2,1,2,3,4,5,6,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10]) == 25350

Answer: assert Solution().getSum(nums = [1,2,3,2,1,2,3,2,1,2,3,2,1]) == 355

Answer: assert Solution().getSum(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 900000

Answer: assert Solution().getSum(nums = [2,3,4,5,6,5,4,3,2,1,2,3,4,5,6,5,4,3,2,1,2,3,4,5,6]) == 6580

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
    def getSum(self, nums: List[int]) -> int:
        def calc(nums: List[int]) -> int:
            n = len(nums)
            left = [0] * n
            right = [0] * n
            cnt = Counter()
            for i in range(1, n):
                cnt[nums[i - 1]] += 1 + cnt[nums[i - 1] - 1]
                left[i] = cnt[nums[i] - 1]
            cnt = Counter()
            for i in range(n - 2, -1, -1):
                cnt[nums[i + 1]] += 1 + cnt[nums[i + 1] + 1]
                right[i] = cnt[nums[i] + 1]
            return sum((l + r + l * r) * x for l, r, x in zip(left, right, nums)) % mod

        mod = 10**9 + 7
        x = calc(nums)
        nums.reverse()
        y = calc(nums)
        return (x + y + sum(nums)) % mod


You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
You are given an array maximumHeight, where maximumHeight[i] denotes the maximum height the ith tower can be assigned.
Your task is to assign a height to each tower so that:

The height of the ith tower is a positive integer and does not exceed maximumHeight[i].
No two towers have the same height.

Return the maximum possible total sum of the tower heights. If it's not possible to assign heights, return -1.

Example 1:

Input: maximumHeight = [2,3,4,3]
Output: 10
Explanation:
We can assign heights in the following way: [1, 2, 4, 3].

Example 2:

Input: maximumHeight = [15,10]
Output: 25
Explanation:
We can assign heights in the following way: [15, 10].

Example 3:

Input: maximumHeight = [2,2,1]
Output: -1
Explanation:
It's impossible to assign positive heights to each index so that no two towers have the same height.

Constraints:

1 <= maximumHeight.length <= 105
1 <= maximumHeight[i] <= 109

Your solution to the problem should be a method of the class Solution called maximumTotalSum and should pass all tests. Use the following starter code:
```python
class Solution:
    def maximumTotalSum(self, maximumHeight: List[int]) -> int:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
You are given an array maximumHeight, where maximumHeight[i] denotes the maximum height the ith tower can be assigned.
Your task is to assign a height to each tower so that:

The height of the ith tower is a positive integer and does not exceed maximumHeight[i].
No two towers have the same height.

Return the maximum possible total sum of the tower heights. If it's not possible to assign heights, return -1.

Example 1:

Input: maximumHeight = [2,3,4,3]
Output: 10
Explanation:
We can assign heights in the following way: [1, 2, 4, 3].

Example 2:

Input: maximumHeight = [15,10]
Output: 25
Explanation:
We can assign heights in the following way: [15, 10].

Example 3:

Input: maximumHeight = [2,2,1]
Output: -1
Explanation:
It's impossible to assign positive heights to each index so that no two towers have the same height.

Constraints:

1 <= maximumHeight.length <= 105
1 <= maximumHeight[i] <= 109

Your solution to the problem should be a method of the class Solution called maximumTotalSum and should pass all tests. Use the following starter code:
```python
class Solution:
    def maximumTotalSum(self, maximumHeight: List[int]) -> int:
        # Add your code here
```

SOLUTION:

assert Solution().maximumTotalSum(maximumHeight = [2,3,4,3]) == 10

assert Solution().maximumTotalSum(maximumHeight = [5,5,5,5,5]) == 15

assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5]) == 15

assert Solution().maximumTotalSum(maximumHeight = [1]) == 1

assert Solution().maximumTotalSum(maximumHeight = [10,9,8,7,6,5,4,3,2,1]) == 55

assert Solution().maximumTotalSum(maximumHeight = [2,2,1]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1,1,1,1,1,1,1,1,1,1]) == -1

assert Solution().maximumTotalSum(maximumHeight = [15,10]) == 25

assert Solution().maximumTotalSum(maximumHeight = [3,3,3,3,2,2,2,1,1,1]) == -1

assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == -1

assert Solution().maximumTotalSum(maximumHeight = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1

assert Solution().maximumTotalSum(maximumHeight = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110

assert Solution().maximumTotalSum(maximumHeight = [5, 5, 5, 5, 5, 5, 5, 5, 5, 10]) == -1

assert Solution().maximumTotalSum(maximumHeight = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1,1,1,1,2,2,2,2,3,3,3,3]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5,6,7,8,9,10]) == 55

assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == -1

assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1

assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 55

assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55

assert Solution().maximumTotalSum(maximumHeight = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 55

assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == -1

assert Solution().maximumTotalSum(maximumHeight = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100

assert Solution().maximumTotalSum(maximumHeight = [1,1,2,2,3,3,4,4,5,5]) == -1

assert Solution().maximumTotalSum(maximumHeight = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1

assert Solution().maximumTotalSum(maximumHeight = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [2,3,4,3]) == 10

Answer: assert Solution().maximumTotalSum(maximumHeight = [5,5,5,5,5]) == 15

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5]) == 15

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000,999999999,999999998,999999997,999999996]) == 4999999990

Answer: assert Solution().maximumTotalSum(maximumHeight = [1]) == 1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000,1000000000,1000000000]) == 2999999997

Answer: assert Solution().maximumTotalSum(maximumHeight = [10,9,8,7,6,5,4,3,2,1]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [2,2,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,1,1,1,1,1,1,1,1,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [15,10]) == 25

Answer: assert Solution().maximumTotalSum(maximumHeight = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 465

Answer: assert Solution().maximumTotalSum(maximumHeight = [3,3,3,3,2,2,2,1,1,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [10,9,8,7,6,5,4,3,2,1,10,9,8,7,6,5,4,3,2,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210

Answer: assert Solution().maximumTotalSum(maximumHeight = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 645

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 5, 5, 5, 5, 5, 5, 5, 5, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,1,1,1,2,2,2,2,3,3,3,3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200

Answer: assert Solution().maximumTotalSum(maximumHeight = [20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]) == 210

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000,1000000000,1000000000,1000000000,1000000000]) == 4999999990

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18,20]) == 210

Answer: assert Solution().maximumTotalSum(maximumHeight = [100, 100, 100, 100, 100, 100, 100, 100, 100, 1]) == 865

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5,6,7,8,9,10]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000,1000000000,1000000000,999999999,999999999]) == 4999999990

Answer: assert Solution().maximumTotalSum(maximumHeight = [100, 100, 99, 98, 97, 96, 95, 94, 93, 92]) == 955

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]) == 210

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000, 1000000000, 1000000000, 1000000000]) == 3999999994

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4999999990

Answer: assert Solution().maximumTotalSum(maximumHeight = [10,10,9,9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,10,10,10,10,10,10,10,10,10,10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,1000000000,1,1000000000,1,1000000000,1,1000000000,1,1000000000]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10945

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325

Answer: assert Solution().maximumTotalSum(maximumHeight = [5,4,3,2,1,1,2,3,4,5,5,4,3,2,1,1,2,3,4,5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100

Answer: assert Solution().maximumTotalSum(maximumHeight = [1,1,2,2,3,3,4,4,5,5]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 9999999955

Answer: assert Solution().maximumTotalSum(maximumHeight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210

Answer: assert Solution().maximumTotalSum(maximumHeight = [20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,1,1,1,1,1,1,1,1,1,1]) == -1

Answer: assert Solution().maximumTotalSum(maximumHeight = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1200

Answer: assert Solution().maximumTotalSum(maximumHeight = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55

Answer: assert Solution().maximumTotalSum(maximumHeight = [10,9,8,7,6,5,4,3,2,1,1,2,3,4,5,6,7,8,9,10]) == -1

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
    def maximumTotalSum(self, maximumHeight: List[int]) -> int:
        maximumHeight.sort()
        ans, mx = 0, inf
        for x in maximumHeight[::-1]:
            x = min(x, mx - 1)
            if x <= 0:
                return -1
            ans += x
            mx = x
        return ans


You are an expert Python programmer. Write correct, efficient Python 3 code that solves the problem and passes all tests. Output the code in the following format: ```python
<code>
```

PROBLEM:
You are given two strings word1 and word2.
A string x is called almost equal to y if you can change at most one character in x to make it identical to y.
A sequence of indices seq is called valid if:

The indices are sorted in ascending order.
Concatenating the characters at these indices in word1 in the same order results in a string that is almost equal to word2.

Return an array of size word2.length representing the lexicographically smallest valid sequence of indices. If no such sequence of indices exists, return an empty array.
Note that the answer must represent the lexicographically smallest array, not the corresponding string formed by those indices.

Example 1:

Input: word1 = "vbcca", word2 = "abc"
Output: [0,1,2]
Explanation:
The lexicographically smallest valid sequence of indices is [0, 1, 2]:

Change word1[0] to 'a'.
word1[1] is already 'b'.
word1[2] is already 'c'.

Example 2:

Input: word1 = "bacdc", word2 = "abc"
Output: [1,2,4]
Explanation:
The lexicographically smallest valid sequence of indices is [1, 2, 4]:

word1[1] is already 'a'.
Change word1[2] to 'b'.
word1[4] is already 'c'.

Example 3:

Input: word1 = "aaaaaa", word2 = "aaabc"
Output: []
Explanation:
There is no valid sequence of indices.

Example 4:

Input: word1 = "abc", word2 = "ab"
Output: [0,1]

Constraints:

1 <= word2.length < word1.length <= 3 * 105
word1 and word2 consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called validSequence and should pass all tests. Use the following starter code:
```python
class Solution:
    def validSequence(self, word1: str, word2: str) -> List[int]:
        # Add your code here
```

SOLUTION:

Question:
PROBLEM:
You are given two strings word1 and word2.
A string x is called almost equal to y if you can change at most one character in x to make it identical to y.
A sequence of indices seq is called valid if:

The indices are sorted in ascending order.
Concatenating the characters at these indices in word1 in the same order results in a string that is almost equal to word2.

Return an array of size word2.length representing the lexicographically smallest valid sequence of indices. If no such sequence of indices exists, return an empty array.
Note that the answer must represent the lexicographically smallest array, not the corresponding string formed by those indices.

Example 1:

Input: word1 = "vbcca", word2 = "abc"
Output: [0,1,2]
Explanation:
The lexicographically smallest valid sequence of indices is [0, 1, 2]:

Change word1[0] to 'a'.
word1[1] is already 'b'.
word1[2] is already 'c'.

Example 2:

Input: word1 = "bacdc", word2 = "abc"
Output: [1,2,4]
Explanation:
The lexicographically smallest valid sequence of indices is [1, 2, 4]:

word1[1] is already 'a'.
Change word1[2] to 'b'.
word1[4] is already 'c'.

Example 3:

Input: word1 = "aaaaaa", word2 = "aaabc"
Output: []
Explanation:
There is no valid sequence of indices.

Example 4:

Input: word1 = "abc", word2 = "ab"
Output: [0,1]

Constraints:

1 <= word2.length < word1.length <= 3 * 105
word1 and word2 consist only of lowercase English letters.

Your solution to the problem should be a method of the class Solution called validSequence and should pass all tests. Use the following starter code:
```python
class Solution:
    def validSequence(self, word1: str, word2: str) -> List[int]:
        # Add your code here
```

SOLUTION:

assert Solution().validSequence(word1 = "hello", word2 = "heo") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abc") == []

assert Solution().validSequence(word1 = "abcde", word2 = "edcba") == []

assert Solution().validSequence(word1 = "abcdefg", word2 = "bdf") == [0, 3, 5]

assert Solution().validSequence(word1 = "mississippi", word2 = "issi") == [0, 2, 3, 4]

assert Solution().validSequence(word1 = "vbcca", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "leetcode", word2 = "code") == [0, 5, 6, 7]

assert Solution().validSequence(word1 = "bacdc", word2 = "abc") == [1, 2, 4]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "aaa") == []

assert Solution().validSequence(word1 = "xyz", word2 = "xy") == [0, 1]

assert Solution().validSequence(word1 = "abcabcabc", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "aaa") == []

assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "xyz") == []

assert Solution().validSequence(word1 = "abcdefghij", word2 = "aceg") == [0, 1, 4, 6]

assert Solution().validSequence(word1 = "xyzz", word2 = "xyz") == [0, 1, 2]

assert Solution().validSequence(word1 = "aabbccddeeff", word2 = "abcdef") == [0, 1, 4, 6, 8, 10]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zzz") == []

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "az") == [0, 1]

assert Solution().validSequence(word1 = "leetcode", word2 = "leet") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abababababab", word2 = "aab") == [0, 1, 3]

assert Solution().validSequence(word1 = "zzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

assert Solution().validSequence(word1 = "aaabaaa", word2 = "aaa") == [0, 1, 2]

assert Solution().validSequence(word1 = "aabbcc", word2 = "abc") == [0, 1, 4]

assert Solution().validSequence(word1 = "aaaaaa", word2 = "aaabc") == []

assert Solution().validSequence(word1 = "mississippi", word2 = "sip") == [0, 1, 8]

assert Solution().validSequence(word1 = "zzzzz", word2 = "aaa") == []

assert Solution().validSequence(word1 = "abababababababababababababababababababababababababababab", word2 = "aaa") == [0, 1, 2]

assert Solution().validSequence(word1 = "abc", word2 = "ab") == [0, 1]

assert Solution().validSequence(word1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", word2 = "aaaaaa") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

assert Solution().validSequence(word1 = "abababababababababab", word2 = "ababab") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "hellohellohello", word2 = "ell") == [0, 2, 3]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 24, 25]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "adgjmoqsuwy") == [0, 1, 6, 9, 12, 14, 16, 18, 20, 22, 24]

assert Solution().validSequence(word1 = "axxayyazz", word2 = "xyz") == [0, 4, 7]

assert Solution().validSequence(word1 = "abracadabra", word2 = "abra") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "qrstuvwxyzz") == []

assert Solution().validSequence(word1 = "zyxzyxzyxzyxzyxzyxzyxzyxzyxzyx", word2 = "zyxzyxzyxzyx") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

assert Solution().validSequence(word1 = "sequenceofcharacters", word2 = "sequence") == [0, 1, 2, 3, 4, 5, 6, 7]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvut") == []

assert Solution().validSequence(word1 = "abracadabra", word2 = "acad") == [0, 1, 3, 6]

assert Solution().validSequence(word1 = "thequickbrownfoxjumpsoverthelazydog", word2 = "thezog") == [0, 1, 2, 3, 10, 34]

assert Solution().validSequence(word1 = "ababababababababab", word2 = "aba") == [0, 1, 2]

assert Solution().validSequence(word1 = "aababababa", word2 = "aaa") == [0, 1, 2]

assert Solution().validSequence(word1 = "xyzz", word2 = "zyx") == []

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "xyz") == [0, 24, 25]

assert Solution().validSequence(word1 = "abcdexyz", word2 = "xyz") == [0, 6, 7]

assert Solution().validSequence(word1 = "xyzxyzxyzxyzxyzxyzxyzxyz", word2 = "xyzxyzxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8]

assert Solution().validSequence(word1 = "abcdefg", word2 = "aceg") == [0, 1, 4, 6]

assert Solution().validSequence(word1 = "axbxcxdxe", word2 = "abcde") == [0, 1, 4, 6, 8]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcde") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "abcdefghij", word2 = "jihgfedcba") == []

assert Solution().validSequence(word1 = "xyxyxyxyxy", word2 = "xyxy") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "aabbaabbaabbaabbaabbaabb", word2 = "aaabb") == [0, 1, 2, 3, 6]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "mnopq") == [0, 13, 14, 15, 16]

assert Solution().validSequence(word1 = "abababababababab", word2 = "abab") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abacabadabacabadabacabadabacabad", word2 = "abcabcabc") == [0, 1, 2, 4, 5, 11, 12, 13, 19]

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvwxy") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]

assert Solution().validSequence(word1 = "abcdabcdabcd", word2 = "abcd") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnop") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

assert Solution().validSequence(word1 = "abcdefghijabcdefghijabcdefghij", word2 = "abcdefghij") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abab") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "aaaabbbbcccc", word2 = "abccba") == []

assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qaz") == [0, 1, 19]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

assert Solution().validSequence(word1 = "bacdefghijklmnopqrstuvwxyz", word2 = "abcdefg") == []

assert Solution().validSequence(word1 = "alibabacloud", word2 = "abcl") == [0, 1, 7, 8]

assert Solution().validSequence(word1 = "aaaaaaaabbbbbbbbbbcccccccccddddddeeeeeeeeeeffffffffff", word2 = "abcdefghij") == []

assert Solution().validSequence(word1 = "bbaabbaabbaabbaabbaabbaabbaab", word2 = "bbabbb") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "abcdefghij", word2 = "afh") == [0, 1, 7]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abc") == []

assert Solution().validSequence(word1 = "abcdexyz", word2 = "abcdef") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "banana", word2 = "an") == [0, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefg") == [0, 1, 2, 3, 4, 5, 6]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstu") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

assert Solution().validSequence(word1 = "abababababababababababababababababababababababababababababababababababababababababababababababababababababababab", word2 = "abab") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "zzzzyyyxxxwwwwvvvvuuuuttttssssrrrrqqqqppppooooonnnnmmmmllllkkkkjjjjiiiihhhhggggffffffeeeeeeeedddddccccbbbaaaa", word2 = "abcdefg") == []

assert Solution().validSequence(word1 = "xyzzyxzyxzyxzyxzyx", word2 = "xyzzyx") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "acacacacacacacacac", word2 = "aaaa") == [0, 1, 2, 4]

assert Solution().validSequence(word1 = "bbaaabbbaaabbbaaabbbaa", word2 = "baaba") == [0, 1, 2, 5, 8]

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]

assert Solution().validSequence(word1 = "banana", word2 = "bana") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zzzyxwvutsrqponmlkjihgfedcba") == []

assert Solution().validSequence(word1 = "abbaabbaabba", word2 = "abab") == [0, 1, 2, 5]

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnopqrstuvwxyz") == [0, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]

assert Solution().validSequence(word1 = "abcdabcabcabcabcabcabcabcabcabcabc", word2 = "abcde") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "abcabcabcabcabcabcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "thisisalongstring", word2 = "this") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "fedcba") == [0, 21, 22, 23, 24, 25]

assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qwertyuiop") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "qrstuv") == [0, 17, 18, 19, 20, 21]

assert Solution().validSequence(word1 = "abcdabc", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdabcdabcdabcd", word2 = "abca") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abada") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "racecar", word2 = "ace") == [0, 2, 3]

assert Solution().validSequence(word1 = "abcabcabcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "bbaaaabaaaabbaa", word2 = "bab") == [0, 1, 6]

assert Solution().validSequence(word1 = "abababababababababab", word2 = "aaa") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdabcdabcdabcd", word2 = "abcdabcd") == [0, 1, 2, 3, 4, 5, 6, 7]

assert Solution().validSequence(word1 = "aaaaabbbbbcccccddddd", word2 = "abcde") == [0, 5, 10, 15, 16]

assert Solution().validSequence(word1 = "xyzzxyzzxyzz", word2 = "xyzxyz") == [0, 1, 2, 3, 5, 6]

assert Solution().validSequence(word1 = "abcdefghiklmnopqrstuvwxyz", word2 = "aikuyz") == [0, 1, 9, 19, 23, 24]

assert Solution().validSequence(word1 = "amazingrace", word2 = "amazing") == [0, 1, 2, 3, 4, 5, 6]

assert Solution().validSequence(word1 = "pythonprogramming", word2 = "python") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "aabbaabbaabbaabb", word2 = "aabb") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "abacabadabacabadabacabad", word2 = "abcabc") == [0, 1, 2, 4, 5, 11]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "xyzabc") == []

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

assert Solution().validSequence(word1 = "acbacbacbac", word2 = "abcabc") == [0, 1, 4, 6, 8, 10]

assert Solution().validSequence(word1 = "abacaba", word2 = "aaa") == [0, 1, 2]

assert Solution().validSequence(word1 = "repeatedrepeatedrepeated", word2 = "repeated") == [0, 1, 2, 3, 4, 5, 6, 7]

assert Solution().validSequence(word1 = "xyzxyzxyzxyzxyzxyzxyz", word2 = "xyzxyz") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "abcdefgabcdefgabcdefgabcdefg", word2 = "abcdefg") == [0, 1, 2, 3, 4, 5, 6]

assert Solution().validSequence(word1 = "aaabbbcccdddeeefffggghhhiii", word2 = "abcdefghi") == [0, 1, 6, 9, 12, 15, 18, 21, 24]

assert Solution().validSequence(word1 = "xyzxyzxyzxyz", word2 = "xyzxyz") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "mississippi", word2 = "miss") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "foobartoobarfoo", word2 = "foobar") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "aabbaabbaabbaabbaabb", word2 = "aabbaab") == [0, 1, 2, 3, 4, 5, 6]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzzzz") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "mississippi", word2 = "mis") == [0, 1, 2]

assert Solution().validSequence(word1 = "hellotherehellotherehellotherehellotherehellotherehellotherehellotherehellotherehellothere", word2 = "here") == [0, 1, 2, 7]

assert Solution().validSequence(word1 = "thisisaverylongstringthatweneedtouse", word2 = "string") == [0, 16, 17, 18, 19, 20]

assert Solution().validSequence(word1 = "xyzzxyzzxyzzxyzz", word2 = "zzzz") == [0, 2, 3, 6]

assert Solution().validSequence(word1 = "abcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "hellothere", word2 = "her") == [0, 1, 2]

assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvw") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44]

assert Solution().validSequence(word1 = "pneumonoultramicroscopicsilicovolcanoconiosis", word2 = "pneumo") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "baaabaaaabaaabaababaaaab", word2 = "baaba") == [0, 1, 2, 3, 5]

assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abaca") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "abcde") == []

assert Solution().validSequence(word1 = "hellohellohellohellohellohello", word2 = "hello") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "hellohellohello", word2 = "helo") == [0, 1, 2, 3]

assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "mnopqrstuvwxyza") == []

assert Solution().validSequence(word1 = "xxxxxxxxxyyyyyyyyyzzzzzzzzz", word2 = "xyz") == [0, 1, 18]

assert Solution().validSequence(word1 = "zyxzyxzyxzyxzyxzyxzyxzyxzyx", word2 = "zyxzyxzyx") == [0, 1, 2, 3, 4, 5, 6, 7, 8]

assert Solution().validSequence(word1 = "abababab", word2 = "aba") == [0, 1, 2]

assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "zyxwv") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "programming", word2 = "pgm") == [0, 1, 6]

assert Solution().validSequence(word1 = "abacabadabacabadabacaba", word2 = "ababa") == [0, 1, 2, 3, 4]

assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

assert Solution().validSequence(word1 = "abacabadabacabadaba", word2 = "abc") == [0, 1, 2]

assert Solution().validSequence(word1 = "aaaabbbbccccddddeeeeffffgggg", word2 = "abcdefg") == [0, 1, 8, 12, 16, 20, 24]

assert Solution().validSequence(word1 = "aaaaaabbbaaaaabaaaaabbbaaa", word2 = "aabbaab") == [0, 1, 2, 6, 9, 10, 14]

assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qwerty") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qzpm") == [0, 1, 9, 25]

assert Solution().validSequence(word1 = "mississippiississippi", word2 = "misis") == [0, 1, 2, 3, 5]

assert Solution().validSequence(word1 = "thisisaverylongstringwithsomerepeatingcharacters", word2 = "thisis") == [0, 1, 2, 3, 4, 5]

assert Solution().validSequence(word1 = "pppppppppppppppppp", word2 = "ppp") == [0, 1, 2]

assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyx") == []

Answer: assert Solution().validSequence(word1 = "hello", word2 = "heo") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abc") == []

Answer: assert Solution().validSequence(word1 = "abcde", word2 = "edcba") == []

Answer: assert Solution().validSequence(word1 = "abcdefg", word2 = "bdf") == [0, 3, 5]

Answer: assert Solution().validSequence(word1 = "mississippi", word2 = "issi") == [0, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "vbcca", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "leetcode", word2 = "code") == [0, 5, 6, 7]

Answer: assert Solution().validSequence(word1 = "bacdc", word2 = "abc") == [1, 2, 4]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "aaa") == []

Answer: assert Solution().validSequence(word1 = "xyz", word2 = "xy") == [0, 1]

Answer: assert Solution().validSequence(word1 = "abcabcabc", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "aaa") == []

Answer: assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "xyz") == []

Answer: assert Solution().validSequence(word1 = "abcdefghij", word2 = "aceg") == [0, 1, 4, 6]

Answer: assert Solution().validSequence(word1 = "xyzz", word2 = "xyz") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aabbccddeeff", word2 = "abcdef") == [0, 1, 4, 6, 8, 10]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zzz") == []

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "az") == [0, 1]

Answer: assert Solution().validSequence(word1 = "leetcode", word2 = "leet") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abababababab", word2 = "aab") == [0, 1, 3]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aaabaaa", word2 = "aaa") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aabbcc", word2 = "abc") == [0, 1, 4]

Answer: assert Solution().validSequence(word1 = "aaaaaa", word2 = "aaabc") == []

Answer: assert Solution().validSequence(word1 = "mississippi", word2 = "sip") == [0, 1, 8]

Answer: assert Solution().validSequence(word1 = "zzzzz", word2 = "aaa") == []

Answer: assert Solution().validSequence(word1 = "abababababababababababababababababababababababababababab", word2 = "aaa") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abc", word2 = "ab") == [0, 1]

Answer: assert Solution().validSequence(word1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", word2 = "aaaaaa") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

Answer: assert Solution().validSequence(word1 = "abababababababababab", word2 = "ababab") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "hellohellohello", word2 = "ell") == [0, 2, 3]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 24, 25]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "adgjmoqsuwy") == [0, 1, 6, 9, 12, 14, 16, 18, 20, 22, 24]

Answer: assert Solution().validSequence(word1 = "axxayyazz", word2 = "xyz") == [0, 4, 7]

Answer: assert Solution().validSequence(word1 = "abracadabra", word2 = "abra") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "qrstuvwxyzz") == []

Answer: assert Solution().validSequence(word1 = "zyxzyxzyxzyxzyxzyxzyxzyxzyxzyx", word2 = "zyxzyxzyxzyx") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

Answer: assert Solution().validSequence(word1 = "sequenceofcharacters", word2 = "sequence") == [0, 1, 2, 3, 4, 5, 6, 7]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyxwvut") == []

Answer: assert Solution().validSequence(word1 = "abracadabra", word2 = "acad") == [0, 1, 3, 6]

Answer: assert Solution().validSequence(word1 = "thequickbrownfoxjumpsoverthelazydog", word2 = "thezog") == [0, 1, 2, 3, 10, 34]

Answer: assert Solution().validSequence(word1 = "ababababababababab", word2 = "aba") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aababababa", word2 = "aaa") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "xyzz", word2 = "zyx") == []

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "xyz") == [0, 24, 25]

Answer: assert Solution().validSequence(word1 = "abcdexyz", word2 = "xyz") == [0, 6, 7]

Answer: assert Solution().validSequence(word1 = "xyzxyzxyzxyzxyzxyzxyzxyz", word2 = "xyzxyzxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8]

Answer: assert Solution().validSequence(word1 = "abcdefg", word2 = "aceg") == [0, 1, 4, 6]

Answer: assert Solution().validSequence(word1 = "axbxcxdxe", word2 = "abcde") == [0, 1, 4, 6, 8]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "zyxwvutsrqponmlkjihgfedcba") == []

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcde") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "abcdefghij", word2 = "jihgfedcba") == []

Answer: assert Solution().validSequence(word1 = "xyxyxyxyxy", word2 = "xyxy") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "aabbaabbaabbaabbaabbaabb", word2 = "aaabb") == [0, 1, 2, 3, 6]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "mnopq") == [0, 13, 14, 15, 16]

Answer: assert Solution().validSequence(word1 = "abababababababab", word2 = "abab") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abacabadabacabadabacabadabacabad", word2 = "abcabcabc") == [0, 1, 2, 4, 5, 11, 12, 13, 19]

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvwxy") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]

Answer: assert Solution().validSequence(word1 = "abcdabcdabcd", word2 = "abcd") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnop") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

Answer: assert Solution().validSequence(word1 = "abcdefghijabcdefghijabcdefghij", word2 = "abcdefghij") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Answer: assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abab") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "aaaabbbbcccc", word2 = "abccba") == []

Answer: assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qaz") == [0, 1, 19]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "bacdefghijklmnopqrstuvwxyz", word2 = "abcdefg") == []

Answer: assert Solution().validSequence(word1 = "alibabacloud", word2 = "abcl") == [0, 1, 7, 8]

Answer: assert Solution().validSequence(word1 = "aaaaaaaabbbbbbbbbbcccccccccddddddeeeeeeeeeeffffffffff", word2 = "abcdefghij") == []

Answer: assert Solution().validSequence(word1 = "bbaabbaabbaabbaabbaabbaabbaab", word2 = "bbabbb") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "abcdefghij", word2 = "afh") == [0, 1, 7]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abc") == []

Answer: assert Solution().validSequence(word1 = "abcdexyz", word2 = "abcdef") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "banana", word2 = "an") == [0, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefg") == [0, 1, 2, 3, 4, 5, 6]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstu") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

Answer: assert Solution().validSequence(word1 = "abababababababababababababababababababababababababababababababababababababababababababababababababababababababab", word2 = "abab") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "zzzzyyyxxxwwwwvvvvuuuuttttssssrrrrqqqqppppooooonnnnmmmmllllkkkkjjjjiiiihhhhggggffffffeeeeeeeedddddccccbbbaaaa", word2 = "abcdefg") == []

Answer: assert Solution().validSequence(word1 = "xyzzyxzyxzyxzyxzyx", word2 = "xyzzyx") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "acacacacacacacacac", word2 = "aaaa") == [0, 1, 2, 4]

Answer: assert Solution().validSequence(word1 = "bbaaabbbaaabbbaaabbbaa", word2 = "baaba") == [0, 1, 2, 5, 8]

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]

Answer: assert Solution().validSequence(word1 = "banana", word2 = "bana") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "zzzyxwvutsrqponmlkjihgfedcba") == []

Answer: assert Solution().validSequence(word1 = "abbaabbaabba", word2 = "abab") == [0, 1, 2, 5]

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "mnopqrstuvwxyz") == [0, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]

Answer: assert Solution().validSequence(word1 = "abcdabcabcabcabcabcabcabcabcabcabc", word2 = "abcde") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "abcabcabcabcabcabcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "thisisalongstring", word2 = "this") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "fedcba") == [0, 21, 22, 23, 24, 25]

Answer: assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qwertyuiop") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "qrstuv") == [0, 17, 18, 19, 20, 21]

Answer: assert Solution().validSequence(word1 = "abcdabc", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdabcdabcdabcd", word2 = "abca") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abada") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "racecar", word2 = "ace") == [0, 2, 3]

Answer: assert Solution().validSequence(word1 = "abcabcabcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "bbaaaabaaaabbaa", word2 = "bab") == [0, 1, 6]

Answer: assert Solution().validSequence(word1 = "abababababababababab", word2 = "aaa") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdabcdabcdabcd", word2 = "abcdabcd") == [0, 1, 2, 3, 4, 5, 6, 7]

Answer: assert Solution().validSequence(word1 = "aaaaabbbbbcccccddddd", word2 = "abcde") == [0, 5, 10, 15, 16]

Answer: assert Solution().validSequence(word1 = "xyzzxyzzxyzz", word2 = "xyzxyz") == [0, 1, 2, 3, 5, 6]

Answer: assert Solution().validSequence(word1 = "abcdefghiklmnopqrstuvwxyz", word2 = "aikuyz") == [0, 1, 9, 19, 23, 24]

Answer: assert Solution().validSequence(word1 = "amazingrace", word2 = "amazing") == [0, 1, 2, 3, 4, 5, 6]

Answer: assert Solution().validSequence(word1 = "pythonprogramming", word2 = "python") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "aabbaabbaabbaabb", word2 = "aabb") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "abacabadabacabadabacabad", word2 = "abcabc") == [0, 1, 2, 4, 5, 11]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "xyzabc") == []

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

Answer: assert Solution().validSequence(word1 = "acbacbacbac", word2 = "abcabc") == [0, 1, 4, 6, 8, 10]

Answer: assert Solution().validSequence(word1 = "abacaba", word2 = "aaa") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "repeatedrepeatedrepeated", word2 = "repeated") == [0, 1, 2, 3, 4, 5, 6, 7]

Answer: assert Solution().validSequence(word1 = "xyzxyzxyzxyzxyzxyzxyz", word2 = "xyzxyz") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "abcdefgabcdefgabcdefgabcdefg", word2 = "abcdefg") == [0, 1, 2, 3, 4, 5, 6]

Answer: assert Solution().validSequence(word1 = "aaabbbcccdddeeefffggghhhiii", word2 = "abcdefghi") == [0, 1, 6, 9, 12, 15, 18, 21, 24]

Answer: assert Solution().validSequence(word1 = "xyzxyzxyzxyz", word2 = "xyzxyz") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "mississippi", word2 = "miss") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "foobartoobarfoo", word2 = "foobar") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "aabbaabbaabbaabbaabb", word2 = "aabbaab") == [0, 1, 2, 3, 4, 5, 6]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzzzzz") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "mississippi", word2 = "mis") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "hellotherehellotherehellotherehellotherehellotherehellotherehellotherehellotherehellothere", word2 = "here") == [0, 1, 2, 7]

Answer: assert Solution().validSequence(word1 = "thisisaverylongstringthatweneedtouse", word2 = "string") == [0, 16, 17, 18, 19, 20]

Answer: assert Solution().validSequence(word1 = "xyzzxyzzxyzzxyzz", word2 = "zzzz") == [0, 2, 3, 6]

Answer: assert Solution().validSequence(word1 = "abcabcabcabcabc", word2 = "abcabc") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "hellothere", word2 = "her") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz", word2 = "abcdefghijklmnopqrstuvw") == [0, 1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44]

Answer: assert Solution().validSequence(word1 = "pneumonoultramicroscopicsilicovolcanoconiosis", word2 = "pneumo") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "baaabaaaabaaabaababaaaab", word2 = "baaba") == [0, 1, 2, 3, 5]

Answer: assert Solution().validSequence(word1 = "abacabadabacaba", word2 = "abaca") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "abcde") == []

Answer: assert Solution().validSequence(word1 = "hellohellohellohellohellohello", word2 = "hello") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "hellohellohello", word2 = "helo") == [0, 1, 2, 3]

Answer: assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "mnopqrstuvwxyza") == []

Answer: assert Solution().validSequence(word1 = "xxxxxxxxxyyyyyyyyyzzzzzzzzz", word2 = "xyz") == [0, 1, 18]

Answer: assert Solution().validSequence(word1 = "zyxzyxzyxzyxzyxzyxzyxzyxzyx", word2 = "zyxzyxzyx") == [0, 1, 2, 3, 4, 5, 6, 7, 8]

Answer: assert Solution().validSequence(word1 = "abababab", word2 = "aba") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "zyxwvutsrqponmlkjihgfedcba", word2 = "zyxwv") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "programming", word2 = "pgm") == [0, 1, 6]

Answer: assert Solution().validSequence(word1 = "abacabadabacabadabacaba", word2 = "ababa") == [0, 1, 2, 3, 4]

Answer: assert Solution().validSequence(word1 = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz", word2 = "zzz") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", word2 = "abcdefghijklmnopqrstuvwxyz") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

Answer: assert Solution().validSequence(word1 = "abacabadabacabadaba", word2 = "abc") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "aaaabbbbccccddddeeeeffffgggg", word2 = "abcdefg") == [0, 1, 8, 12, 16, 20, 24]

Answer: assert Solution().validSequence(word1 = "aaaaaabbbaaaaabaaaaabbbaaa", word2 = "aabbaab") == [0, 1, 2, 6, 9, 10, 14]

Answer: assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qwerty") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "qwertyuiopasdfghjklzxcvbnm", word2 = "qzpm") == [0, 1, 9, 25]

Answer: assert Solution().validSequence(word1 = "mississippiississippi", word2 = "misis") == [0, 1, 2, 3, 5]

Answer: assert Solution().validSequence(word1 = "thisisaverylongstringwithsomerepeatingcharacters", word2 = "thisis") == [0, 1, 2, 3, 4, 5]

Answer: assert Solution().validSequence(word1 = "pppppppppppppppppp", word2 = "ppp") == [0, 1, 2]

Answer: assert Solution().validSequence(word1 = "abcdefghijklmnopqrstuvwxyz", word2 = "zyx") == []

import random
import functools
import collections
import string
import math
import datetime

from typing import *
from functools import *
from collections import *
from itertools import *
from heapq import *
from bisect import *
from string import *
from operator import *
from math import *

inf = float('inf')

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def list_node(values: list):
    if not values:
        return None
    head = ListNode(values[0])
    p = head
    for val in values[1:]:
        node = ListNode(val)
        p.next = node
        p = node
    return head

def is_same_list(p1, p2):
    if p1 is None and p2 is None:
        return True
    if not p1 or not p2:
        return False
    return p1.val == p2.val and is_same_list(p1.next, p2.next)

class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def tree_node(values: list):
    if not values:
        return None
    root = TreeNode(values[0])
    i = 1
    queue = deque()
    queue.append(root)
    while queue:
        node = queue.popleft()
        if i < len(values) and values[i] is not None:
            node.left = TreeNode(values[i])
            queue.append(node.left)
        i += 1
        if i < len(values) and values[i] is not None:
            node.right = TreeNode(values[i])
            queue.append(node.right)
        i += 1
    return root

def is_same_tree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return is_same_tree(p.left, q.left) and is_same_tree(p.right, q.right)

class Solution:
  def validSequence(self, word1: str, word2: str) -> list[int]:
    ans = []
    # last[j] := the index i of the last occurrence in word1, where
    # word1[i] == word2[j]
    last = [-1] * len(word2)

    i = len(word1) - 1
    j = len(word2) - 1
    while i >= 0 and j >= 0:
      if word1[i] == word2[j]:
        last[j] = i
        j -= 1
      i -= 1

    canSkip = True
    j = 0
    for i, c in enumerate(word1):
      if j == len(word2):
        break
      if c == word2[j]:
        ans.append(i)
        j += 1
      elif canSkip and (j == len(word2) - 1 or i < last[j + 1]):
        canSkip = False
        ans.append(i)
        j += 1

    return ans if j == len(word2) else []

class Solution:
    def validSequence(self, word1: str, word2: str) -> List[int]: