Dataset Viewer
slug_name
stringlengths 3
58
| meta_info
dict | id
stringlengths 1
3
| difficulty
stringclasses 3
values | pretty_content
listlengths 1
1
| solutions
listlengths 3
36
| prompt
stringlengths 120
527
| generator_code
stringlengths 72
1.58k
| convert_online
stringclasses 16
values | convert_offline
stringclasses 13
values | evaluate_offline
stringclasses 11
values | entry_point
stringlengths 3
31
| test_cases
stringlengths 1.56k
32.9M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
spiral-matrix
|
{
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>Given an <code>m x n</code> <code>matrix</code>, return <em>all elements of the</em> <code>matrix</code> <em>in spiral order</em>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/11/13/spiral1.jpg\" style=\"width: 242px; height: 242px;\" />\n<pre>\n<strong>Input:</strong> matrix = [[1,2,3],[4,5,6],[7,8,9]]\n<strong>Output:</strong> [1,2,3,6,9,8,7,4,5]\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/11/13/spiral.jpg\" style=\"width: 322px; height: 242px;\" />\n<pre>\n<strong>Input:</strong> matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]\n<strong>Output:</strong> [1,2,3,4,8,12,11,10,9,5,6,7]\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>m == matrix.length</code></li>\n\t<li><code>n == matrix[i].length</code></li>\n\t<li><code>1 <= m, n <= 10</code></li>\n\t<li><code>-100 <= matrix[i][j] <= 100</code></li>\n</ul>\n",
"difficulty": "Medium",
"questionFrontendId": "54",
"questionId": "54",
"questionTitle": "Spiral Matrix",
"questionTitleSlug": "spiral-matrix",
"similarQuestions": "[{\"title\": \"Spiral Matrix II\", \"titleSlug\": \"spiral-matrix-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Spiral Matrix III\", \"titleSlug\": \"spiral-matrix-iii\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Spiral Matrix IV\", \"titleSlug\": \"spiral-matrix-iv\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
"stats": "{\"totalAccepted\": \"1.3M\", \"totalSubmission\": \"2.6M\", \"totalAcceptedRaw\": 1260175, \"totalSubmissionRaw\": 2618561, \"acRate\": \"48.1%\"}",
"topicTags": [
{
"name": "Array",
"slug": "array"
},
{
"name": "Matrix",
"slug": "matrix"
},
{
"name": "Simulation",
"slug": "simulation"
}
]
}
}
}
|
54
|
Medium
|
[
"Given an m x n matrix, return all elements of the matrix in spiral order.\n\n \nExample 1:\n\nInput: matrix = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [1,2,3,6,9,8,7,4,5]\n\n\nExample 2:\n\nInput: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]\nOutput: [1,2,3,4,8,12,11,10,9,5,6,7]\n\n\n \nConstraints:\n\n\n\tm == matrix.length\n\tn == matrix[i].length\n\t1 <= m, n <= 10\n\t-100 <= matrix[i][j] <= 100\n\n\n"
] |
[
{
"hash": -7901417908281767000,
"runtime": "44ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n \n top = left = 0\n bottom = len(matrix)-1\n right = len(matrix[0])-1\n ans = []\n while left<=right and top<=bottom:\n\n for i in range(left,right+1):\n ans.append(matrix[top][i])\n\n top +=1\n\n for i in range(top,bottom+1):\n ans.append(matrix[i][right])\n\n right-=1\n\n if top<= bottom:\n\n for i in range(right,left-1,-1):\n ans.append(matrix[bottom][i])\n\n bottom-=1\n\n if left<=right:\n\n for i in range(bottom,top-1,-1):\n ans.append(matrix[i][left])\n\n left+=1\n\n return ans"
},
{
"hash": 2979623801820750300,
"runtime": "36ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n if not matrix or not matrix[0]:\n return []\n\n result = []\n top, bottom = 0, len(matrix) - 1\n left, right = 0, len(matrix[0]) - 1\n\n while left <= right and top <= bottom:\n # Traverse top row\n for i in range(left, right + 1):\n result.append(matrix[top][i])\n top += 1\n\n # Traverse right column\n for i in range(top, bottom + 1):\n result.append(matrix[i][right])\n right -= 1\n\n # Traverse bottom row\n if top <= bottom:\n for i in range(right, left - 1, -1):\n result.append(matrix[bottom][i])\n bottom -= 1\n\n # Traverse left column\n if left <= right:\n for i in range(bottom, top - 1, -1):\n result.append(matrix[i][left])\n left += 1\n\n return result"
},
{
"hash": 5830702755919632000,
"runtime": "24ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n if not matrix:\n return []\n\n rows, cols = len(matrix), len(matrix[0])\n top, bottom, left, right = 0, rows-1, 0, cols-1\n result = []\n \n while len(result) < rows * cols:\n for i in range(left, right+1):\n result.append(matrix[top][i])\n top += 1\n \n for i in range(top, bottom+1):\n result.append(matrix[i][right])\n right -= 1\n \n if top <= bottom:\n for i in range(right, left-1, -1):\n result.append(matrix[bottom][i])\n bottom -= 1\n \n if left <= right:\n for i in range(bottom, top-1, -1):\n result.append(matrix[i][left])\n left += 1\n \n return result"
},
{
"hash": 6143528053069975000,
"runtime": "56ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n result = []\n while matrix:\n result += (matrix.pop(0))\n if matrix and matrix[0]:\n result += ([row.pop() for row in matrix])\n if matrix:\n result += matrix.pop()[::-1]\n if matrix and matrix[0]:\n result += ([row.pop(0) for row in matrix][::-1])\n return result"
},
{
"hash": -6407230161003952000,
"runtime": "60ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n result = []\n while matrix:\n result += matrix.pop(0)\n matrix = (list(zip(*matrix)))[::-1]\n return result"
},
{
"hash": 471172117717305150,
"runtime": "68ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n res = []\n left,right = 0, len(matrix[0])\n top , bottom = 0,len(matrix)\n while left < right and top < bottom:\n #from left to right\n for a in range(left, right):\n res.append(matrix[top][a])\n top +=1\n \n #from top to bottom \n for a in range(top , bottom):\n res.append(matrix[a][right-1])\n right -=1\n \n #break loop if we dont have left to right\n if not (left < right and top < bottom):\n break\n \n #from right to left\n for a in range(right-1 , left-1 , -1):\n res.append(matrix[bottom-1][a])\n bottom -=1\n # break\n \n #from bottom to up \n for a in range(bottom-1, top-1, -1):\n res.append(matrix[a][left])\n left +=1\n \n return res"
},
{
"hash": -4981930739436859000,
"runtime": "20ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n first_row = 0\n last_row = len(matrix) - 1\n first_col = 0\n last_col = len(matrix[0]) - 1\n\n output = []\n\n while True: # Revisit\n # top\n output.extend(matrix[first_row][first_col:last_col + 1])\n first_row += 1\n\n if first_row > last_row:\n break\n\n # right\n for i in range(first_row, last_row + 1):\n output.append(matrix[i][last_col])\n last_col -= 1\n\n if first_col > last_col:\n break\n\n # bottom\n output.extend([matrix[last_row][j] for j in range(last_col, first_col-1, -1)])\n last_row -= 1\n\n if first_row > last_row:\n break\n\n # left\n for k in range(last_row, first_row - 1, -1):\n output.append(matrix[k][first_col])\n first_col += 1\n\n if first_col > last_col:\n break\n\n return output"
},
{
"hash": -4488399605146645500,
"runtime": "52ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n row , col = len(matrix), len(matrix[0])\n u, d, l, r = 0, row-1, 0, col-1\n ans = []\n while len(ans) < (row*col):\n for i in range(l, r+1):\n ans.append(matrix[u][i])\n u += 1\n\n for i in range(u, d+1):\n ans.append(matrix[i][r])\n r -= 1\n\n if u <= d:\n for i in range(r, l-1, -1):\n ans.append(matrix[d][i])\n d -= 1\n if l <= r:\n for i in range(d, u-1, -1): \n ans.append(matrix[i][l])\n l+=1\n return ans"
},
{
"hash": -7303749964658191000,
"runtime": "64ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n ans = []\n # boundaries\n left, right = 0, len(matrix[0])-1\n top, bottom = 0, len(matrix)-1\n\n while left <= right and top <= bottom:\n # right\n for c in range(left, right+1):\n ans.append(matrix[top][c])\n top += 1\n \n # down\n for r in range(top, bottom+1):\n ans.append(matrix[r][right])\n right -= 1\n\n if not (left <= right and top <= bottom):\n break\n\n # left\n for c in range(right, left-1, -1):\n ans.append(matrix[bottom][c])\n bottom -= 1\n\n # up\n for r in range(bottom, top-1, -1):\n ans.append(matrix[r][left])\n left += 1\n\n return ans"
},
{
"hash": 2531128780300420600,
"runtime": "28ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n result =[]\n if len(matrix) ==1:\n return matrix[0]\n if len(matrix)==0:\n return []\n result += matrix.pop(0)\n print(result)\n if len(matrix)!=0 and len(matrix[0])!=0:\n for row in range(len(matrix)):\n result.append(matrix[row].pop(-1))\n print (result)\n if len(matrix)!=0 and len(matrix[-1])!=0:\n a=matrix.pop(-1)\n a.reverse()\n result +=a\n print(result)\n print(matrix)\n if len(matrix)!=0 and len(matrix[0])!=0:\n col1 = []\n for row in range (len(matrix)):\n col1.append(matrix[row].pop(0))\n col1.reverse()\n result+=col1\n print(result)\n print(matrix)\n result+=self.spiralOrder(matrix)\n print(result)\n return result\n "
},
{
"hash": 1625463847752106800,
"runtime": "48ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n ans = []\n\n leftToRightStartIndex = 0\n leftToRightEndIndex = len(matrix[0])\n\n upToDownStartIndex = 0\n upToDownEndIndex = len(matrix)\n\n rightToLeftStartIndex = len(matrix[0]) - 1\n rightToLeftEndIndex = 0\n\n downToUpStartIndex = len(matrix) - 1\n downToUpEndIndex = 1\n\n while leftToRightStartIndex <= rightToLeftStartIndex and upToDownStartIndex <= downToUpStartIndex:\n for iterator in range(leftToRightStartIndex, leftToRightEndIndex):\n ans.append(matrix[upToDownStartIndex][iterator])\n\n for iterator in range(upToDownStartIndex + 1, upToDownEndIndex):\n ans.append(matrix[iterator][rightToLeftStartIndex])\n\n if upToDownStartIndex < downToUpStartIndex:\n for iterator in range(rightToLeftStartIndex - 1, rightToLeftEndIndex - 1, -1):\n ans.append(matrix[downToUpStartIndex][iterator])\n\n if leftToRightStartIndex < rightToLeftStartIndex:\n for iterator in range(downToUpStartIndex - 1, upToDownStartIndex, -1):\n ans.append(matrix[iterator][leftToRightStartIndex])\n\n leftToRightStartIndex += 1\n leftToRightEndIndex -= 1\n upToDownStartIndex += 1\n upToDownEndIndex -= 1\n rightToLeftStartIndex -= 1\n rightToLeftEndIndex += 1\n downToUpStartIndex -= 1\n downToUpEndIndex += 1\n\n return ans\n\n\n\n\n\n\n \n\n\n "
},
{
"hash": 1359650924783587800,
"runtime": "40ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n m, n = len(matrix), len(matrix[0])\n row_t, row_b, col_l, col_r = 0, m-1, 0, n-1\n res = []\n\n while row_t <= row_b and col_l <= col_r:\n # Go through top row\n for j in range(col_l, col_r + 1):\n res.append(matrix[row_t][j])\n\n # Go through last col, starting at 2nd to first row\n for i in range(row_t + 1, row_b + 1):\n res.append(matrix[i][col_r])\n\n # Go through last row, starting at 2nd to last col\n if row_t != row_b: # If row_t == row_b, we've already gone through the last row since it's also the first row\n for j in range(col_r - 1, col_l - 1, -1):\n res.append(matrix[row_b][j])\n\n # Go through first col, starting at 2nd to last row up to the 2nd to first row\n if col_l != col_r: # If col_l == col_r, we've already gone through the first col since it's also the last col\n for i in range(row_b - 1, row_t, -1):\n res.append(matrix[i][col_l])\n\n row_t, row_b, col_l, col_r = row_t + 1, row_b - 1, col_l + 1, col_r - 1\n\n return res\n\n# Time Complexity: O(mn) Go through all elements\n# Space Complexity: O(mn) Will store all elements in res array"
},
{
"hash": -5179929568505096000,
"runtime": "32ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n m, n = len(matrix), len(matrix[0])\n res = []\n for o in range(0, min(m, n) // 2 + 1):\n left = o\n right = n- o - 1\n up = o\n down = m - o - 1\n print(left, right, up, down)\n if down < up or right < left:\n continue\n #if up == down and left == right:\n # res.append(matrix[up][left])\n # continue\n for j in range(left, right):\n res.append(matrix[up][j])\n if up == down:\n res.append(matrix[up][right])\n continue\n for i in range(up, down):\n res.append(matrix[i][right])\n if left == right:\n res.append(matrix[down][right])\n continue\n for j in range(right, left, -1):\n res.append(matrix[down][j])\n for i in range(down, up, -1):\n res.append(matrix[i][left])\n return res"
},
{
"hash": -5842837003432618000,
"runtime": "14ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n xmin = -1\n xmax = len(matrix)\n ymin = -1\n ymax = len(matrix[0])\n x = y = 0\n res = [matrix[0][0]]\n\n while xmin <= xmax and ymin <= ymax:\n for i, direction in enumerate([[0,1],[1,0],[0,-1],[-1,0]]):\n while xmin < x + direction[0] < xmax and ymin < y + direction[1] < ymax:\n x += direction[0]\n y += direction[1]\n res.append(matrix[x][y])\n if i == 0:\n xmin += 1\n elif i == 1:\n ymax -= 1\n elif i == 2:\n xmax -= 1\n elif i == 3:\n ymin += 1\n if xmin + 1 == xmax or ymin + 1 == ymax:\n break\n return res"
}
] |
class Solution(object):
def spiralOrder(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: List[int]
"""
|
import random
def generate_test_case():
m = random.randint(1, 10)
n = random.randint(1, 10)
return [[random.randint(-100, 100) for _ in range(n)] for _ in range(m)]
|
def convert_online(case):
return case
|
def convert_offline(case):
return case
|
def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False
|
spiralOrder
|
[{"input": [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], "expected": [1, 2, 3, 6, 9, 8, 7, 4, 5]}, {"input": [[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]], "expected": [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]}, {"input": [[[-88, -52, 62, -29, -4, 20, 59, -57], [76, 56, -93, 38, 85, -15, -96, 48], [-4, -30, 63, -87, -94, -35, -27, 56], [-59, -55, -99, 28, 44, 78, 57, 3]]], "expected": [-88, -52, 62, -29, -4, 20, 59, -57, 48, 56, 3, 57, 78, 44, 28, -99, -55, -59, -4, 76, 56, -93, 38, 85, -15, -96, -27, -35, -94, -87, 63, -30]}, {"input": [[[-38], [86], [-43], [-36]]], "expected": [-38, 86, -43, -36]}, {"input": [[[-48, 100, -10, 6, -30], [86, -44, 60, -22, -15]]], "expected": [-48, 100, -10, 6, -30, -15, -22, 60, -44, 86]}, {"input": [[[84, 78, -62, -100, -24, -9, -23, -98], [71, -36, 97, 8, 40, -14, -93, -59], [38, -51, -21, -5, -66, 44, -98, 46], [44, 20, -10, 33, -25, -14, 24, 10], [-70, -53, 23, 73, -65, -26, 63, 76]]], "expected": [84, 78, -62, -100, -24, -9, -23, -98, -59, 46, 10, 76, 63, -26, -65, 73, 23, -53, -70, 44, 38, 71, -36, 97, 8, 40, -14, -93, -98, 24, -14, -25, 33, -10, 20, -51, -21, -5, -66, 44]}, {"input": [[[-43, -10, 70, -93, 47, 36, -43, 35], [62, -45, -75, -36, -70, 64, 42, 7], [-24, -32, -26, -14, -36, -15, -62, 69], [34, -41, -58, 47, 7, 42, 92, -98], [-29, 38, 38, 81, -36, -5, -77, -90], [-17, -71, 78, 88, -1, 48, -57, -28], [-56, -46, -14, 21, -2, 28, -99, 87]]], "expected": [-43, -10, 70, -93, 47, 36, -43, 35, 7, 69, -98, -90, -28, 87, -99, 28, -2, 21, -14, -46, -56, -17, -29, 34, -24, 62, -45, -75, -36, -70, 64, 42, -62, 92, -77, -57, 48, -1, 88, 78, -71, 38, -41, -32, -26, -14, -36, -15, 42, -5, -36, 81, 38, -58, 47, 7]}, {"input": [[[-13, -32], [25, 59], [82, 94], [68, 72], [-97, -66], [81, 73], [17, 5], [-28, -13]]], "expected": [-13, -32, 59, 94, 72, -66, 73, 5, -13, -28, 17, 81, -97, 68, 82, 25]}, {"input": [[[68, -9, 99], [-85, 61, -7], [-9, -4, 5], [96, -89, -54], [10, -95, 68], [-58, -72, 95], [66, 12, -92]]], "expected": [68, -9, 99, -7, 5, -54, 68, 95, -92, 12, 66, -58, 10, 96, -9, -85, 61, -4, -89, -95, -72]}, {"input": [[[-30, -46, 100, -39], [40, 56, -95, -87], [-19, -29, 90, 91], [41, 62, -90, -27], [56, 9, -41, 30]]], "expected": [-30, -46, 100, -39, -87, 91, -27, 30, -41, 9, 56, 41, -19, 40, 56, -95, 90, -90, 62, -29]}, {"input": [[[96, -94, -98, 38, 31], [32, 33, 40, -26, 10], [89, -69, -85, 17, 24], [-50, 58, 68, -67, 49], [80, 32, 88, -33, -25]]], "expected": [96, -94, -98, 38, 31, 10, 24, 49, -25, -33, 88, 32, 80, -50, 89, 32, 33, 40, -26, 17, -67, 68, 58, -69, -85]}, {"input": [[[-1, -67, 65, 1, -96, -80, 78], [-44, -11, -5, 19, 50, -23, -74], [44, -53, 91, -34, -38, -31, -35], [-25, -30, 65, -42, -10, -36, 9], [52, 34, -62, -22, 18, 13, 91], [-94, 8, 31, -9, -49, -96, -82]]], "expected": [-1, -67, 65, 1, -96, -80, 78, -74, -35, 9, 91, -82, -96, -49, -9, 31, 8, -94, 52, -25, 44, -44, -11, -5, 19, 50, -23, -31, -36, 13, 18, -22, -62, 34, -30, -53, 91, -34, -38, -10, -42, 65]}, {"input": [[[47, -56, -91, -17, -35, -81, 59], [1, -26, 8, 15, 34, -86, -93], [90, 79, -17, -45, -43, -54, 52], [-21, -81, -36, 57, -80, -37, -50], [-73, 8, -66, -68, 27, -50, -1], [-23, -19, 68, 85, -1, 86, -51], [-5, 37, 82, -67, 51, 66, 67], [-49, -14, 6, 37, -71, 53, 70]]], "expected": [47, -56, -91, -17, -35, -81, 59, -93, 52, -50, -1, -51, 67, 70, 53, -71, 37, 6, -14, -49, -5, -23, -73, -21, 90, 1, -26, 8, 15, 34, -86, -54, -37, -50, 86, 66, 51, -67, 82, 37, -19, 8, -81, 79, -17, -45, -43, -80, 27, -1, 85, 68, -66, -36, 57, -68]}, {"input": [[[55, -81, -71, -67, 86, -39, 48, -19, 26], [49, 48, 67, 3, 97, 98, -70, 79, 46], [-82, -2, -40, -92, -74, 74, 54, -52, 78], [-88, 48, 44, 79, -5, -60, 5, -94, 97]]], "expected": [55, -81, -71, -67, 86, -39, 48, -19, 26, 46, 78, 97, -94, 5, -60, -5, 79, 44, 48, -88, -82, 49, 48, 67, 3, 97, 98, -70, 79, -52, 54, 74, -74, -92, -40, -2]}, {"input": [[[54, 11, -87, -52, -16, -30], [43, -62, -89, -33, -12, 13], [81, 72, 53, 61, 81, -4]]], "expected": [54, 11, -87, -52, -16, -30, 13, -4, 81, 61, 53, 72, 81, 43, -62, -89, -33, -12]}, {"input": [[[8, -30, -43, -79, -84, 64], [75, 39, -23, -88, 41, -88], [-76, -33, -93, -7, -7, 89], [31, 32, 46, 0, -51, -67], [-12, -57, 83, -15, -56, 3], [-12, -77, -17, -65, -95, -53], [-33, 65, -48, -9, -5, -52], [-51, 55, 2, -68, -78, 35], [-46, -2, -51, 89, -19, 7], [-76, 17, 66, 1, -92, 1]]], "expected": [8, -30, -43, -79, -84, 64, -88, 89, -67, 3, -53, -52, 35, 7, 1, -92, 1, 66, 17, -76, -46, -51, -33, -12, -12, 31, -76, 75, 39, -23, -88, 41, -7, -51, -56, -95, -5, -78, -19, 89, -51, -2, 55, 65, -77, -57, 32, -33, -93, -7, 0, -15, -65, -9, -68, 2, -48, -17, 83, 46]}, {"input": [[[80, -51, 94, 8, -73, -52, 55], [6, -85, -85, -85, 34, -16, 41], [-70, 16, 87, 61, 7, 76, -33], [5, -95, -14, 42, -11, 90, 19], [-98, -82, -59, 73, -94, 10, 2], [-76, -58, 80, -75, -47, -9, 38], [-98, -82, 12, 100, 66, -14, -76], [99, 100, -65, 55, 23, -74, -60], [-63, -40, -69, 45, -5, -21, 12], [-51, 30, -99, -33, 96, 54, -60]]], "expected": [80, -51, 94, 8, -73, -52, 55, 41, -33, 19, 2, 38, -76, -60, 12, -60, 54, 96, -33, -99, 30, -51, -63, 99, -98, -76, -98, 5, -70, 6, -85, -85, -85, 34, -16, 76, 90, 10, -9, -14, -74, -21, -5, 45, -69, -40, 100, -82, -58, -82, -95, 16, 87, 61, 7, -11, -94, -47, 66, 23, 55, -65, 12, 80, -59, -14, 42, 73, -75, 100]}, {"input": [[[-27, 28, 94], [-17, -34, 66]]], "expected": [-27, 28, 94, 66, -34, -17]}, {"input": [[[69, 4, -14, 63, 35], [54, 95, 57, -13, 100], [67, 59, 14, -23, -54], [89, -36, -12, -32, -55], [-24, 85, 58, -38, 80]]], "expected": [69, 4, -14, 63, 35, 100, -54, -55, 80, -38, 58, 85, -24, 89, 67, 54, 95, 57, -13, -23, -32, -12, -36, 59, 14]}, {"input": [[[65, 100, -22, 79, 95], [-23, -60, -80, -28, -80], [-70, -94, 2, -62, 6], [-26, 47, 38, 7, -60], [100, -69, -57, -80, -100], [96, 42, -48, -59, -50], [57, -52, -4, -29, 41], [-31, -35, 69, 42, 100], [15, -39, 48, 40, -45]]], "expected": [65, 100, -22, 79, 95, -80, 6, -60, -100, -50, 41, 100, -45, 40, 48, -39, 15, -31, 57, 96, 100, -26, -70, -23, -60, -80, -28, -62, 7, -80, -59, -29, 42, 69, -35, -52, 42, -69, 47, -94, 2, 38, -57, -48, -4]}, {"input": [[[-32], [-24], [-98], [55], [45], [91], [-62]]], "expected": [-32, -24, -98, 55, 45, 91, -62]}, {"input": [[[-19, -57, 44, 24, -27, -95, 67, -14], [41, 84, 94, 71, 21, 34, 86, -12], [98, 53, 62, -5, 18, 71, -45, 6], [-53, 58, -95, -72, -14, -85, 45, 76], [53, -48, -51, 69, -46, -66, 17, 51], [54, 72, 95, -25, 57, 37, -84, -10], [29, -22, -47, 11, 38, -71, 66, 46]]], "expected": [-19, -57, 44, 24, -27, -95, 67, -14, -12, 6, 76, 51, -10, 46, 66, -71, 38, 11, -47, -22, 29, 54, 53, -53, 98, 41, 84, 94, 71, 21, 34, 86, -45, 45, 17, -84, 37, 57, -25, 95, 72, -48, 58, 53, 62, -5, 18, 71, -85, -66, -46, 69, -51, -95, -72, -14]}, {"input": [[[-46, -26], [-74, 10], [-73, -67], [-45, -28], [-81, -30]]], "expected": [-46, -26, 10, -67, -28, -30, -81, -45, -73, -74]}, {"input": [[[82, 90, 42, 14, 31, -51, 7, 42, 5, -79], [-12, -44, -83, 88, -95, 47, -28, -23, 30, 34], [44, 55, -14, -30, -3, -83, -78, 96, 96, -67], [27, 63, 12, -72, 40, 52, 70, 81, 1, -44], [-80, 39, 5, 72, 53, -80, -90, -39, -41, 28], [-25, 59, 84, 90, -85, 15, 11, -36, -91, -5], [90, -25, -57, -24, -20, 7, -35, -16, -30, 76], [-74, 8, 62, -68, 31, 74, -90, 32, 26, -20], [62, 6, -17, 61, 59, 99, 53, -79, 60, 47]]], "expected": [82, 90, 42, 14, 31, -51, 7, 42, 5, -79, 34, -67, -44, 28, -5, 76, -20, 47, 60, -79, 53, 99, 59, 61, -17, 6, 62, -74, 90, -25, -80, 27, 44, -12, -44, -83, 88, -95, 47, -28, -23, 30, 96, 1, -41, -91, -30, 26, 32, -90, 74, 31, -68, 62, 8, -25, 59, 39, 63, 55, -14, -30, -3, -83, -78, 96, 81, -39, -36, -16, -35, 7, -20, -24, -57, 84, 5, 12, -72, 40, 52, 70, -90, 11, 15, -85, 90, 72, 53, -80]}, {"input": [[[77, 24, 81, 74, -26], [-41, 37, 60, 34, 70]]], "expected": [77, 24, 81, 74, -26, 70, 34, 60, 37, -41]}, {"input": [[[-91, -61], [-45, 71], [-4, 75], [-67, -36], [64, 66], [-3, -16], [11, 62]]], "expected": [-91, -61, 71, 75, -36, 66, -16, 62, 11, -3, 64, -67, -4, -45]}, {"input": [[[-6, 77, 99, 10, 53], [-24, 53, -16, -23, -51], [94, 22, 47, 45, 72], [28, 19, 56, -77, 36], [49, -10, 26, -67, -3], [32, 95, -76, -34, 11], [-57, 74, -27, -97, 86], [-33, 16, 58, -8, 53], [-71, 90, -73, 50, 67]]], "expected": [-6, 77, 99, 10, 53, -51, 72, 36, -3, 11, 86, 53, 67, 50, -73, 90, -71, -33, -57, 32, 49, 28, 94, -24, 53, -16, -23, 45, -77, -67, -34, -97, -8, 58, 16, 74, 95, -10, 19, 22, 47, 56, 26, -76, -27]}, {"input": [[[-43, -55, 35, 63, 60, 92, -9], [-28, 21, -78, -5, -97, -1, 22], [47, 0, -100, -14, -38, -69, 66]]], "expected": [-43, -55, 35, 63, 60, 92, -9, 22, 66, -69, -38, -14, -100, 0, 47, -28, 21, -78, -5, -97, -1]}, {"input": [[[-90, -92, 76], [49, -89, -68], [73, 63, -57]]], "expected": [-90, -92, 76, -68, -57, 63, 73, 49, -89]}, {"input": [[[33, -83]]], "expected": [33, -83]}, {"input": [[[-40, -10, 83, -30, -12, -67, -1], [-48, 86, 78, 93, -74, -99, -15]]], "expected": [-40, -10, 83, -30, -12, -67, -1, -15, -99, -74, 93, 78, 86, -48]}, {"input": [[[39, 47, -66, 5, 100, -74, -41], [-48, -94, -15, -86, -51, 12, 13], [57, -40, 28, -49, 4, -41, 23], [48, -85, -10, 6, 86, -89, 26], [-32, -58, -1, 53, -12, 87, 5], [-53, -17, -2, -91, -35, 94, -7], [81, 58, 99, -92, 4, 51, 0], [-99, 55, 57, 69, -57, 51, 60], [-96, 10, 57, -26, 56, -27, -4], [-7, 84, -74, 44, -82, -91, -6]]], "expected": [39, 47, -66, 5, 100, -74, -41, 13, 23, 26, 5, -7, 0, 60, -4, -6, -91, -82, 44, -74, 84, -7, -96, -99, 81, -53, -32, 48, 57, -48, -94, -15, -86, -51, 12, -41, -89, 87, 94, 51, 51, -27, 56, -26, 57, 10, 55, 58, -17, -58, -85, -40, 28, -49, 4, 86, -12, -35, 4, -57, 69, 57, 99, -2, -1, -10, 6, 53, -91, -92]}, {"input": [[[48, 16, 2, -67, -6, -82, 100, 60, 99], [57, 89, 87, -47, -65, 72, -86, -12, -15], [97, -40, 58, 83, -2, 39, -48, -72, -16], [-57, -45, -40, -56, 5, -60, 97, -73, -81], [76, 90, 5, 35, -28, 8, 21, -64, -68], [4, 2, -5, -57, -82, -23, -38, -66, -4], [-63, 0, -3, -63, -92, -58, -22, -28, 38], [-76, 41, 9, -41, -99, -100, 66, 59, 44], [-68, 78, 100, -65, -32, 93, 2, 98, -78], [-62, 42, 24, 95, 65, -77, 8, -81, -81]]], "expected": [48, 16, 2, -67, -6, -82, 100, 60, 99, -15, -16, -81, -68, -4, 38, 44, -78, -81, -81, 8, -77, 65, 95, 24, 42, -62, -68, -76, -63, 4, 76, -57, 97, 57, 89, 87, -47, -65, 72, -86, -12, -72, -73, -64, -66, -28, 59, 98, 2, 93, -32, -65, 100, 78, 41, 0, 2, 90, -45, -40, 58, 83, -2, 39, -48, 97, 21, -38, -22, 66, -100, -99, -41, 9, -3, -5, 5, -40, -56, 5, -60, 8, -23, -58, -92, -63, -57, 35, -28, -82]}, {"input": [[[54, 6], [-83, 26], [-76, -20]]], "expected": [54, 6, 26, -20, -76, -83]}, {"input": [[[-90, -53, 69], [-27, -20, 37], [-20, 31, -81], [-2, 46, 50], [58, 38, -99], [-42, 28, -65], [35, -33, -68]]], "expected": [-90, -53, 69, 37, -81, 50, -99, -65, -68, -33, 35, -42, 58, -2, -20, -27, -20, 31, 46, 38, 28]}, {"input": [[[22, 18, 94], [-82, -78, -92], [9, -81, -31], [60, -30, -44], [-59, -72, -77], [71, 19, -6], [-11, 89, 79], [-61, -53, -59]]], "expected": [22, 18, 94, -92, -31, -44, -77, -6, 79, -59, -53, -61, -11, 71, -59, 60, 9, -82, -78, -81, -30, -72, 19, 89]}, {"input": [[[23], [70], [11], [3], [88], [59], [80], [80], [94], [-41]]], "expected": [23, 70, 11, 3, 88, 59, 80, 80, 94, -41]}, {"input": [[[24, -52, -79], [37, -48, 57], [39, 27, -13], [51, 88, 5], [-11, -73, 6], [-61, 56, -57], [8, -8, -37], [71, -75, 56], [-31, -30, 37]]], "expected": [24, -52, -79, 57, -13, 5, 6, -57, -37, 56, 37, -30, -31, 71, 8, -61, -11, 51, 39, 37, -48, 27, 88, -73, 56, -8, -75]}, {"input": [[[-80, 52], [-63, 4], [51, 99], [-50, 58], [60, 68], [-75, -30]]], "expected": [-80, 52, 4, 99, 58, 68, -30, -75, 60, -50, 51, -63]}, {"input": [[[96, 54, -7, -1, 68, -91, 65, 73, 98, -61]]], "expected": [96, 54, -7, -1, 68, -91, 65, 73, 98, -61]}, {"input": [[[-23, 82, -38, 51, 46, -24, 49, 73, -100], [-47, 11, -46, -31, -95, -12, -96, 91, 59], [-80, 56, -75, -98, -41, 11, 8, 63, 41], [-82, -67, -65, -3, 55, -61, -59, -4, 42], [-7, -50, 55, -31, 74, 27, -58, 36, 78], [42, -61, -90, 1, -100, 44, -54, 29, -14], [39, 6, 16, -17, 51, 61, -74, 92, -29], [37, -57, -56, 30, -53, -30, -16, 99, -93], [28, -78, 82, -46, -16, -79, -12, -12, -61], [-8, 37, 70, -10, 53, 3, -64, -41, 23]]], "expected": [-23, 82, -38, 51, 46, -24, 49, 73, -100, 59, 41, 42, 78, -14, -29, -93, -61, 23, -41, -64, 3, 53, -10, 70, 37, -8, 28, 37, 39, 42, -7, -82, -80, -47, 11, -46, -31, -95, -12, -96, 91, 63, -4, 36, 29, 92, 99, -12, -12, -79, -16, -46, 82, -78, -57, 6, -61, -50, -67, 56, -75, -98, -41, 11, 8, -59, -58, -54, -74, -16, -30, -53, 30, -56, 16, -90, 55, -65, -3, 55, -61, 27, 44, 61, 51, -17, 1, -31, 74, -100]}, {"input": [[[-86, -85, 48, -74], [-32, -40, -77, 36], [-27, -98, -85, -14]]], "expected": [-86, -85, 48, -74, 36, -14, -85, -98, -27, -32, -40, -77]}, {"input": [[[-100, 27, -61, -100, -13], [45, -75, 81, -82, 11], [-53, 21, 66, 69, 21], [56, -73, -8, 45, -47], [33, 85, 77, -100, 7], [-79, 71, 96, -24, -54], [69, 96, -37, -30, 35], [-28, 64, 15, -48, -16], [-9, 17, -3, -57, -74], [59, 70, -81, -100, -82]]], "expected": [-100, 27, -61, -100, -13, 11, 21, -47, 7, -54, 35, -16, -74, -82, -100, -81, 70, 59, -9, -28, 69, -79, 33, 56, -53, 45, -75, 81, -82, 69, 45, -100, -24, -30, -48, -57, -3, 17, 64, 96, 71, 85, -73, 21, 66, -8, 77, 96, -37, 15]}, {"input": [[[-36, 7, 93, -92, 74], [82, 73, -44, -51, 15], [-56, -60, 36, -20, -72], [-6, 56, -17, -93, -54], [-13, -16, 10, -2, 35]]], "expected": [-36, 7, 93, -92, 74, 15, -72, -54, 35, -2, 10, -16, -13, -6, -56, 82, 73, -44, -51, -20, -93, -17, 56, -60, 36]}, {"input": [[[-24, -53, 1, 94, -2, -82, 28, 39, -93, -26], [-6, 30, -77, 26, 10, -19, 51, 19, 3, 63], [-58, -40, -56, -99, -81, 20, -73, -85, -87, 60]]], "expected": [-24, -53, 1, 94, -2, -82, 28, 39, -93, -26, 63, 60, -87, -85, -73, 20, -81, -99, -56, -40, -58, -6, 30, -77, 26, 10, -19, 51, 19, 3]}, {"input": [[[59, 45, -71, -59, 70, 67, -68, -55, 80, -49], [-76, 74, 60, -15, 37, 34, -59, -1, 70, -51], [92, -7, 86, -52, 39, -57, 81, -96, -79, -10], [-16, 58, -23, -17, -28, 25, -71, 49, -54, 59], [-77, -82, 85, -76, 20, -98, -96, 87, 97, 81]]], "expected": [59, 45, -71, -59, 70, 67, -68, -55, 80, -49, -51, -10, 59, 81, 97, 87, -96, -98, 20, -76, 85, -82, -77, -16, 92, -76, 74, 60, -15, 37, 34, -59, -1, 70, -79, -54, 49, -71, 25, -28, -17, -23, 58, -7, 86, -52, 39, -57, 81, -96]}, {"input": [[[27, -15, -22, -13, 10], [-29, -78, -22, 77, 40], [-69, -96, -32, 78, -49], [96, -63, 93, -5, 24]]], "expected": [27, -15, -22, -13, 10, 40, -49, 24, -5, 93, -63, 96, -69, -29, -78, -22, 77, 78, -32, -96]}, {"input": [[[66, 41, 55, 20, -68, -25], [-10, 50, -11, -76, 11, 56], [-73, 50, -75, 49, -42, -46], [38, 84, 99, -62, 79, -81], [28, 94, 68, 56, -76, -5], [30, -35, -59, -67, 90, -35], [47, -75, 21, 59, 11, 26], [45, -9, -73, -37, 11, 11], [75, 65, 62, -55, 25, -56]]], "expected": [66, 41, 55, 20, -68, -25, 56, -46, -81, -5, -35, 26, 11, -56, 25, -55, 62, 65, 75, 45, 47, 30, 28, 38, -73, -10, 50, -11, -76, 11, -42, 79, -76, 90, 11, 11, -37, -73, -9, -75, -35, 94, 84, 50, -75, 49, -62, 56, -67, 59, 21, -59, 68, 99]}, {"input": [[[-98, 73, 71, -18, -3], [79, 28, 63, -63, -79], [-51, 64, 89, 91, 40], [80, -56, -53, -75, 84], [82, -46, 74, 3, -88], [-54, -24, 19, 72, 3], [-96, -39, -25, 35, 75], [-1, -77, -56, 82, 57], [-25, -98, 0, 89, 45], [-39, -48, 58, 0, 17]]], "expected": [-98, 73, 71, -18, -3, -79, 40, 84, -88, 3, 75, 57, 45, 17, 0, 58, -48, -39, -25, -1, -96, -54, 82, 80, -51, 79, 28, 63, -63, 91, -75, 3, 72, 35, 82, 89, 0, -98, -77, -39, -24, -46, -56, 64, 89, -53, 74, 19, -25, -56]}, {"input": [[[83], [98]]], "expected": [83, 98]}]
|
summary-ranges
|
{
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>You are given a <strong>sorted unique</strong> integer array <code>nums</code>.</p>\n\n<p>A <strong>range</strong> <code>[a,b]</code> is the set of all integers from <code>a</code> to <code>b</code> (inclusive).</p>\n\n<p>Return <em>the <strong>smallest sorted</strong> list of ranges that <strong>cover all the numbers in the array exactly</strong></em>. That is, each element of <code>nums</code> is covered by exactly one of the ranges, and there is no integer <code>x</code> such that <code>x</code> is in one of the ranges but not in <code>nums</code>.</p>\n\n<p>Each range <code>[a,b]</code> in the list should be output as:</p>\n\n<ul>\n\t<li><code>"a->b"</code> if <code>a != b</code></li>\n\t<li><code>"a"</code> if <code>a == b</code></li>\n</ul>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,1,2,4,5,7]\n<strong>Output:</strong> ["0->2","4->5","7"]\n<strong>Explanation:</strong> The ranges are:\n[0,2] --> "0->2"\n[4,5] --> "4->5"\n[7,7] --> "7"\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,2,3,4,6,8,9]\n<strong>Output:</strong> ["0","2->4","6","8->9"]\n<strong>Explanation:</strong> The ranges are:\n[0,0] --> "0"\n[2,4] --> "2->4"\n[6,6] --> "6"\n[8,9] --> "8->9"\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>0 <= nums.length <= 20</code></li>\n\t<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>\n\t<li>All the values of <code>nums</code> are <strong>unique</strong>.</li>\n\t<li><code>nums</code> is sorted in ascending order.</li>\n</ul>\n",
"difficulty": "Easy",
"questionFrontendId": "228",
"questionId": "228",
"questionTitle": "Summary Ranges",
"questionTitleSlug": "summary-ranges",
"similarQuestions": "[{\"title\": \"Missing Ranges\", \"titleSlug\": \"missing-ranges\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Data Stream as Disjoint Intervals\", \"titleSlug\": \"data-stream-as-disjoint-intervals\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Find Maximal Uncovered Ranges\", \"titleSlug\": \"find-maximal-uncovered-ranges\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
"stats": "{\"totalAccepted\": \"486.5K\", \"totalSubmission\": \"976K\", \"totalAcceptedRaw\": 486527, \"totalSubmissionRaw\": 975968, \"acRate\": \"49.9%\"}",
"topicTags": [
{
"name": "Array",
"slug": "array"
}
]
}
}
}
|
228
|
Easy
|
[
"You are given a sorted unique integer array nums.\n\nA range [a,b] is the set of all integers from a to b (inclusive).\n\nReturn the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is in one of the ranges but not in nums.\n\nEach range [a,b] in the list should be output as:\n\n\n\t\"a->b\" if a != b\n\t\"a\" if a == b\n\n\n \nExample 1:\n\nInput: nums = [0,1,2,4,5,7]\nOutput: [\"0->2\",\"4->5\",\"7\"]\nExplanation: The ranges are:\n[0,2] --> \"0->2\"\n[4,5] --> \"4->5\"\n[7,7] --> \"7\"\n\n\nExample 2:\n\nInput: nums = [0,2,3,4,6,8,9]\nOutput: [\"0\",\"2->4\",\"6\",\"8->9\"]\nExplanation: The ranges are:\n[0,0] --> \"0\"\n[2,4] --> \"2->4\"\n[6,6] --> \"6\"\n[8,9] --> \"8->9\"\n\n\n \nConstraints:\n\n\n\t0 <= nums.length <= 20\n\t-2³¹ <= nums[i] <= 2³¹ - 1\n\tAll the values of nums are unique.\n\tnums is sorted in ascending order.\n\n\n"
] |
[
{
"hash": -7164636124794358000,
"runtime": "25ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n result = []\n for num in nums:\n if not result or num > result[-1][-1] + 1:\n result.append([num, num])\n else:\n result[-1][-1] = num\n\n return [f\"{start}->{end}\" if start != end else str(start) for start, end in result]"
},
{
"hash": -610055105292270600,
"runtime": "57ms",
"solution": "class Solution:\n def convertToString(self,a,b):\n if a == b:\n return str(a)\n return f\"{a}->{b}\"\n\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if len(nums) == 0:\n return []\n c = nums[0]\n res = []\n ranges = []\n\n for n in nums:\n if c == n :\n res.append(n)\n c+=1\n else:\n ranges.append(self.convertToString(res[0],res[-1]))\n res = [n]\n c=n+1\n ranges.append(self.convertToString(res[0],res[-1]))\n return ranges"
},
{
"hash": -387992612879749200,
"runtime": "61ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n i=0\n res=[]\n if(len(nums)==0):\n return res\n while (i<len(nums)):\n j=i+1\n while (j <len(nums)):\n if (nums[j-1]+1==nums[j]):\n j+=1\n else:\n break\n\n if(j-i==1):\n res.append(str(nums[i]))\n else:\n res.append(str(nums[i])+'->'+ str(nums[j-1]))\n i=j\n return res\n\n\n "
},
{
"hash": 7681762457804031000,
"runtime": "45ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if nums == []:\n return []\n\n res = [[nums[0], nums[0]]]\n\n for i in range(1,len(nums)):\n if nums[i] == res[-1][-1] + 1:\n res[-1][-1] = nums[i]\n else:\n res.append([nums[i],nums[i]])\n res_str = []\n for interval in res:\n if interval[0] == interval[1]:\n res_str.append(str(interval[0]))\n else:\n res_str.append(str(interval[0]) + '->' + str(interval[1]))\n \n return res_str"
},
{
"hash": 2305265996071320600,
"runtime": "37ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n i=0\n result=[]\n if (len(nums)==0):\n return []\n while(i<len(nums)):\n j=i+1\n while(j<len(nums)):\n if (nums[j-1]+1==nums[j]):\n j+=1\n else:\n break\n if(j-i==1):\n result.append(str(nums[i]))\n else:\n result.append(str(nums[i])+'->'+str(nums[j-1]))\n i=j\n return result\n "
},
{
"hash": -9077146075495433000,
"runtime": "41ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not nums:\n return []\n l = []\n n = len(nums)\n f = 0\n j = nums[0]\n for i in range(0,n-1):\n if nums[i]==(nums[i+1]-1):\n f+=1\n elif f==0:\n l.append(str(j))\n j = nums[i+1]\n else:\n f=0\n l.append(str(j)+\"->\"+str(nums[i]))\n j = nums[i+1]\n if f==0:\n l.append(str(j))\n else:\n l.append(str(j)+\"->\"+str(nums[-1]))\n return l\n\n\n"
},
{
"hash": -6656311541810915000,
"runtime": "33ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not nums:\n return nums \n start = nums[0]\n end = 0 \n res = []\n\n for i in range(len(nums)-1): \n\n if nums[i+1] == nums[i] + 1: \n end = nums[i+1]\n else: \n if start != nums[i] and end:\n res.append(f\"{start}->{end}\")\n else: \n res.append(str(nums[i]))\n\n start = nums[i+1]\n\n if start != nums[-1]: \n res.append(f\"{start}->{end}\" if end else str(start))\n else: \n res.append(str(nums[-1]))\n\n return res "
},
{
"hash": 8493611874207758000,
"runtime": "14ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not nums: return []\n start = nums[0]\n end = None\n res = []\n for i in range(1, len(nums)):\n if nums[i] == nums[i-1]+1: # increase range\n # print(nums[i])\n end = nums[i]\n else:\n if end != None:\n res.append(str(start)+'->'+str(end))\n end = None\n else:\n res.append(str(start))\n start = nums[i]\n if end != None:\n res.append(str(start)+'->'+str(end))\n else:\n res.append(str(start))\n return res\n\n "
},
{
"hash": -566456619022086500,
"runtime": "49ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not nums:\n return None\n\n ans=[]\n j=0\n for i in range(len(nums)):\n if i+1==len(nums) or nums[i]+1!=nums[i+1]:\n if j==i:\n ans.append(str(nums[i]))\n\n else:\n ans.append(str(nums[j])+\"->\"+str(nums[i]))\n j=i+1\n\n return ans \n if not nums:\n return None\n res = []\n start = 0 \n for i in range(1,len(nums)):\n if i+1==len(nums) or num[i+1]!=nums[i]+1:\n if i == start:\n res.append(str(nums[i]))\n else:\n res.append(str(start)+\"->\"+str(nums[i]))\n start=i+1\n return res"
},
{
"hash": -8779185276189677000,
"runtime": "65ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if nums == []:\n return []\n ans=[]\n a=nums[0]\n b=nums[0]\n for i in nums[1:]:\n if i == b +1:\n b=i\n else:\n if a==b:\n ans.append(str(a))\n else:\n ans.append(f\"{a}->{b}\")\n a=i\n b=i\n if a==b:\n ans.append(str(a))\n else:\n ans.append(f\"{a}->{b}\")\n return ans "
},
{
"hash": 1305361363754454800,
"runtime": "29ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not nums:\n return []\n if len(nums) == 1:\n return [str(nums[0])]\n ans = []\n i = 1\n while i < len(nums):\n data = \"\"\n if nums[i] - nums[i-1] != 1:\n data += str(nums[i-1])\n ans.append(data)\n else:\n data = str(nums[i-1]) + \"->\"\n while i < len(nums) and nums[i] - nums[i-1] == 1 :\n i += 1 \n data += str(nums[i-1])\n ans.append(data)\n i += 1\n index = 0\n if ans[-1].find(\">\") != -1:\n index = ans[-1].index(\">\")\n if ans[-1][index+1:] != str(nums[-1]):\n ans.append(str(nums[-1]))\n return ans"
},
{
"hash": -8427999250983471000,
"runtime": "57ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n if not len(nums):\n return []\n\n range_list = []\n start = nums[0]\n current = nums[0]\n for index in range(len(nums)):\n if nums[index] != current and nums[index - 1] != start:\n range_list.append(f\"{start}->{nums[index - 1]}\")\n start = nums[index]\n current = nums[index]\n\n if nums[index] != current and nums[index - 1] == start:\n range_list.append(f\"{start}\")\n start = nums[index]\n current = nums[index]\n current += 1\n if start == nums[-1]:\n range_list.append(f\"{start}\")\n else:\n range_list.append(f\"{start}->{nums[-1]}\")\n return range_list\n \n\n\n\n\n \n\n"
},
{
"hash": 6973621247220566000,
"runtime": "61ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n res = []\n i = 0\n while i<len(nums):\n start = nums[i]\n while i+1<len(nums) and nums[i]+1 == nums[i+1]:\n i += 1\n if start != nums[i]:\n res.append(str(start)+ \"->\" + str(nums[i]))\n else:\n res.append(str(nums[i]))\n i += 1\n return res\n "
},
{
"hash": 2294393014576113700,
"runtime": "21ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n \n ans = []\n\n if len(nums) == 0:\n return ans\n\n curr = [nums[0]]\n for i in range(1, len(nums)):\n if nums[i] == curr[-1] + 1:\n curr.append(nums[i])\n else:\n if len(curr) == 1:\n ans.append(str(curr[0]))\n elif len(curr) > 1:\n ans.append(''.join([str(curr[0]), '->', str(curr[-1])]))\n \n curr = [nums[i]]\n \n if len(curr) == 1:\n ans.append(str(curr[0]))\n elif len(curr) > 1:\n ans.append(''.join([str(curr[0]), '->', str(curr[-1])]))\n\n return ans\n"
},
{
"hash": 4687890854845188000,
"runtime": "53ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n\n if not nums:\n return []\n\n first = nums.pop(0)\n nums.append(first)\n n_ext = first + 1\n aux = [first]\n res = []\n while nums:\n el = nums.pop(0)\n if el == n_ext:\n aux.append(el)\n n_ext = el + 1\n else:\n if len(aux) == 1:\n res.append(str(aux[-1]))\n else:\n s = str(aux[0]) + '->' + str(aux[-1])\n res.append(s)\n \n n_ext = el + 1\n aux = [el]\n \n\n return res\n \n\n\n\n \n"
}
] |
class Solution(object):
def summaryRanges(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""
|
import random
def generate_test_case():
length = random.randint(0, 20)
nums = sorted(random.sample(range(-2**31, 2**31 - 1), length))
return nums
|
def convert_online(case):
return case
|
def convert_offline(case):
return case
|
def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False
|
summaryRanges
|
[{"input": [[0, 1, 2, 4, 5, 7]], "expected": ["0->2", "4->5", "7"]}, {"input": [[0, 2, 3, 4, 6, 8, 9]], "expected": ["0", "2->4", "6", "8->9"]}, {"input": [[588674346, 1857543781, 2003596430]], "expected": ["588674346", "1857543781", "2003596430"]}, {"input": [[-2121171139, 341570958, 344432966, 1014930966, 1218511757, 1406367912]], "expected": ["-2121171139", "341570958", "344432966", "1014930966", "1218511757", "1406367912"]}, {"input": [[-1518330519, -226650892]], "expected": ["-1518330519", "-226650892"]}, {"input": [[-1893667718, -1568959434, 1949113376, 2085770475]], "expected": ["-1893667718", "-1568959434", "1949113376", "2085770475"]}, {"input": [[-1602851780, -578797443, 43144166, 1966996738]], "expected": ["-1602851780", "-578797443", "43144166", "1966996738"]}, {"input": [[-1239204067, -706640751, 894039163]], "expected": ["-1239204067", "-706640751", "894039163"]}, {"input": [[-2140549595, -1856508474, -1848037481, -1730852581, -1576881630, -1190836438, -1160797587, -971470008, -550577386, -470169802, -396885615, 99380281, 689766101, 1021741025, 1141217500, 1543841737, 1894160868]], "expected": ["-2140549595", "-1856508474", "-1848037481", "-1730852581", "-1576881630", "-1190836438", "-1160797587", "-971470008", "-550577386", "-470169802", "-396885615", "99380281", "689766101", "1021741025", "1141217500", "1543841737", "1894160868"]}, {"input": [[-1536434970, -1353718943, -1105346319, -968157426, -904165171, -891104314, -792304658, -488675915, -258131169, 226428578, 342651404, 370801070, 1012604873, 1812397450, 2014272992, 2109829444]], "expected": ["-1536434970", "-1353718943", "-1105346319", "-968157426", "-904165171", "-891104314", "-792304658", "-488675915", "-258131169", "226428578", "342651404", "370801070", "1012604873", "1812397450", "2014272992", "2109829444"]}, {"input": [[-2081611918, -1985719191, -1651588284, -1599872292, -1432714977, -1057600234, -858244787, -562660175, 254694327, 1223790212, 2071772111]], "expected": ["-2081611918", "-1985719191", "-1651588284", "-1599872292", "-1432714977", "-1057600234", "-858244787", "-562660175", "254694327", "1223790212", "2071772111"]}, {"input": [[-2082842004, -1990008223, -1039602524, -694459690, -593613055, -106341215, -97354299, 431981038, 816286579, 951824588, 1018810868, 1028351547, 1851860188, 2002721214]], "expected": ["-2082842004", "-1990008223", "-1039602524", "-694459690", "-593613055", "-106341215", "-97354299", "431981038", "816286579", "951824588", "1018810868", "1028351547", "1851860188", "2002721214"]}, {"input": [[-1813515779, -401542765, 952074658, 2064207657, 2118653044]], "expected": ["-1813515779", "-401542765", "952074658", "2064207657", "2118653044"]}, {"input": [[-1922672416, -1699031704, -1418479581, -1392176908, -1047530360, -1042566042, -508706343, 215609589, 541595718, 698156749, 1023333133, 1432276262, 1633391295]], "expected": ["-1922672416", "-1699031704", "-1418479581", "-1392176908", "-1047530360", "-1042566042", "-508706343", "215609589", "541595718", "698156749", "1023333133", "1432276262", "1633391295"]}, {"input": [[-1661339631, -1400802010, 331791509]], "expected": ["-1661339631", "-1400802010", "331791509"]}, {"input": [[-1861003428, -1786146846, -1573255909, -1572484298, -1283347885, -792543549, -722463811, -658736971, -317647992, 48263854, 151074947, 177876677, 407863308, 764098307, 1139003196, 1691710752, 2043376906]], "expected": ["-1861003428", "-1786146846", "-1573255909", "-1572484298", "-1283347885", "-792543549", "-722463811", "-658736971", "-317647992", "48263854", "151074947", "177876677", "407863308", "764098307", "1139003196", "1691710752", "2043376906"]}, {"input": [[398819608]], "expected": ["398819608"]}, {"input": [[-410667416, 657667032, 719472822, 1962276722, 2105891782]], "expected": ["-410667416", "657667032", "719472822", "1962276722", "2105891782"]}, {"input": [[-1785305903, -1451089499, -967479008, -951839702, -781302568, 194151549, 980522271, 1150282712, 1324339968, 1523429071]], "expected": ["-1785305903", "-1451089499", "-967479008", "-951839702", "-781302568", "194151549", "980522271", "1150282712", "1324339968", "1523429071"]}, {"input": [[1691223473]], "expected": ["1691223473"]}, {"input": [[-1919156084, -1883555225, -1495121200, -1434724049, -1363526339, -1259842273, -1232498771, -877050448, -783433277, -24193701, 298042544, 442001798, 822297180, 1536136780, 1580265938, 1916336793, 2139337594]], "expected": ["-1919156084", "-1883555225", "-1495121200", "-1434724049", "-1363526339", "-1259842273", "-1232498771", "-877050448", "-783433277", "-24193701", "298042544", "442001798", "822297180", "1536136780", "1580265938", "1916336793", "2139337594"]}, {"input": [[-2010318542, -1850315486, -1465016876, -1357309384, -640213792, 191160501, 483346207, 572468578, 869788563, 1257302573, 1657191332, 1925962927]], "expected": ["-2010318542", "-1850315486", "-1465016876", "-1357309384", "-640213792", "191160501", "483346207", "572468578", "869788563", "1257302573", "1657191332", "1925962927"]}, {"input": [[-1792606390, -1715067359, -1448088483, -251070514, -3497260, 267867572, 383200853, 596537112, 801418575, 1232821586, 1627796657]], "expected": ["-1792606390", "-1715067359", "-1448088483", "-251070514", "-3497260", "267867572", "383200853", "596537112", "801418575", "1232821586", "1627796657"]}, {"input": [[-1179748820, -890714914, -872621325, -651232152, -554081460, -344070434, -330863648, -195022132, 499146136, 1122537176, 1671063641, 1745754383, 1821480404, 1848564759, 1887932373, 2092259495]], "expected": ["-1179748820", "-890714914", "-872621325", "-651232152", "-554081460", "-344070434", "-330863648", "-195022132", "499146136", "1122537176", "1671063641", "1745754383", "1821480404", "1848564759", "1887932373", "2092259495"]}, {"input": [[-2054032931, -2030151264, -1838842789, -1244011069, -851608289, -703522447, -647821378, 83727855, 311830050, 406788394, 411085979, 892482730, 1059672080, 1508675112]], "expected": ["-2054032931", "-2030151264", "-1838842789", "-1244011069", "-851608289", "-703522447", "-647821378", "83727855", "311830050", "406788394", "411085979", "892482730", "1059672080", "1508675112"]}, {"input": [[-1518954553, -1511474571, -1502057967, -1058154222, 1573539753, 1631773101, 1850923436, 2063361161]], "expected": ["-1518954553", "-1511474571", "-1502057967", "-1058154222", "1573539753", "1631773101", "1850923436", "2063361161"]}, {"input": [[-1964429621, -358422417, -97775074, 62518538, 1539977443]], "expected": ["-1964429621", "-358422417", "-97775074", "62518538", "1539977443"]}, {"input": [[-1965102681, -1802980460]], "expected": ["-1965102681", "-1802980460"]}, {"input": [[-1896972102, -1385344947, -1196706859, -852151092, -818928052, -776533682, -618733262, -38258600, 794377632, 880742963, 1168278483, 1292367715, 1681674015, 1775667417]], "expected": ["-1896972102", "-1385344947", "-1196706859", "-852151092", "-818928052", "-776533682", "-618733262", "-38258600", "794377632", "880742963", "1168278483", "1292367715", "1681674015", "1775667417"]}, {"input": [[1239501044, 1271533609]], "expected": ["1239501044", "1271533609"]}, {"input": [[-738953391, -463515132, -409891204, 173009872]], "expected": ["-738953391", "-463515132", "-409891204", "173009872"]}, {"input": [[-1971776891, -1416394437, -1354275672, -1203419847, -1167720238, -1151432052, -176096791, 387076213, 720415099, 810970077, 942421171, 1510464222, 1550738014, 1718348568, 1754116748, 1816781849, 2055804043]], "expected": ["-1971776891", "-1416394437", "-1354275672", "-1203419847", "-1167720238", "-1151432052", "-176096791", "387076213", "720415099", "810970077", "942421171", "1510464222", "1550738014", "1718348568", "1754116748", "1816781849", "2055804043"]}, {"input": [[-1824031301, -1581224056, -1570730563, -1431573780, -1376267491, -602537904, -27530817, -17461916, 371711345, 386558672, 503019684, 716152510, 836951389, 1195308798, 1736284743, 1890985035, 1892275449]], "expected": ["-1824031301", "-1581224056", "-1570730563", "-1431573780", "-1376267491", "-602537904", "-27530817", "-17461916", "371711345", "386558672", "503019684", "716152510", "836951389", "1195308798", "1736284743", "1890985035", "1892275449"]}, {"input": [[-518812639, -490587289, -443250762, -443020009, -388778474, -385634030, -104839318, 249741027, 1368290353, 1689794899]], "expected": ["-518812639", "-490587289", "-443250762", "-443020009", "-388778474", "-385634030", "-104839318", "249741027", "1368290353", "1689794899"]}, {"input": [[]], "expected": []}, {"input": [[-1651554149, 272370863]], "expected": ["-1651554149", "272370863"]}, {"input": [[-1413945230, -714514861, -666944760, -608970419, -595826543, -441227180, -265830246, -22473053, 847846501, 1127926965, 1270637638, 1848482117, 1998445990, 2118765016]], "expected": ["-1413945230", "-714514861", "-666944760", "-608970419", "-595826543", "-441227180", "-265830246", "-22473053", "847846501", "1127926965", "1270637638", "1848482117", "1998445990", "2118765016"]}, {"input": [[-2133286722, -2079904349, -1554097971, -942927568, -245431549, -192680901, 100467087, 1166207979, 1378119088]], "expected": ["-2133286722", "-2079904349", "-1554097971", "-942927568", "-245431549", "-192680901", "100467087", "1166207979", "1378119088"]}, {"input": [[-1782777433, -1590686452, -1245060649, -1066745452, -1035879868, -824961936, -696546780, -195047578, -97356779, -28829195, 337423934, 442052491, 450338904, 740482758, 870830309, 1823580242, 1888449986]], "expected": ["-1782777433", "-1590686452", "-1245060649", "-1066745452", "-1035879868", "-824961936", "-696546780", "-195047578", "-97356779", "-28829195", "337423934", "442052491", "450338904", "740482758", "870830309", "1823580242", "1888449986"]}, {"input": [[-2114767327, -2020299869, -1986988155, -840579934, -784560473, -48234235, 65908202, 277561626, 785058567, 858965683, 882672871, 1475433112, 1651792424, 1658539264]], "expected": ["-2114767327", "-2020299869", "-1986988155", "-840579934", "-784560473", "-48234235", "65908202", "277561626", "785058567", "858965683", "882672871", "1475433112", "1651792424", "1658539264"]}, {"input": [[-2102426101, -2010387258, -1882723045, -1854486831, -1236235680, -1128482744, -1119323512, -1091377283, -634290511, -507437270, -259791762, -73786477, 69198111, 86753876, 378914007, 385211924, 554390156, 1229829210, 1771117612, 2043859223]], "expected": ["-2102426101", "-2010387258", "-1882723045", "-1854486831", "-1236235680", "-1128482744", "-1119323512", "-1091377283", "-634290511", "-507437270", "-259791762", "-73786477", "69198111", "86753876", "378914007", "385211924", "554390156", "1229829210", "1771117612", "2043859223"]}, {"input": [[-1514127243, -1475620258, -712603488, 886046467, 1084459958, 2109599264]], "expected": ["-1514127243", "-1475620258", "-712603488", "886046467", "1084459958", "2109599264"]}, {"input": [[-1536744005, 1628501609]], "expected": ["-1536744005", "1628501609"]}, {"input": [[-2091758367, -2040294747, -1314505200, -995564737, -875826370, -823525982, -667127967, -628741943, -593548007, -322108599, -17628424, 62660451, 135055669, 690686254, 1212139541, 1216371725, 1401559708, 1990627637]], "expected": ["-2091758367", "-2040294747", "-1314505200", "-995564737", "-875826370", "-823525982", "-667127967", "-628741943", "-593548007", "-322108599", "-17628424", "62660451", "135055669", "690686254", "1212139541", "1216371725", "1401559708", "1990627637"]}, {"input": [[]], "expected": []}, {"input": [[-2058038033, -1755515087, -1741740398, -1486783509, -1400743497, -727502736, -648516539, 449477712, 753871194, 1237123041, 1247872485, 1323526218, 1347594449, 1502027309, 1746792559, 2051713146]], "expected": ["-2058038033", "-1755515087", "-1741740398", "-1486783509", "-1400743497", "-727502736", "-648516539", "449477712", "753871194", "1237123041", "1247872485", "1323526218", "1347594449", "1502027309", "1746792559", "2051713146"]}, {"input": [[495951647]], "expected": ["495951647"]}, {"input": [[-1680954717, -1123727912, 621478511, 1004380551, 1629835727, 1912427748, 2043634880]], "expected": ["-1680954717", "-1123727912", "621478511", "1004380551", "1629835727", "1912427748", "2043634880"]}, {"input": [[-1677793370, -1021704783, -173362681, 359933268, 1104560837, 1361428027]], "expected": ["-1677793370", "-1021704783", "-173362681", "359933268", "1104560837", "1361428027"]}, {"input": [[-1871536876, -1772383177, -810254825, -175590344, -47690974, 100013703, 145317453, 222578569, 830982948, 1056642632, 1115215543, 1960690660, 2027652572]], "expected": ["-1871536876", "-1772383177", "-810254825", "-175590344", "-47690974", "100013703", "145317453", "222578569", "830982948", "1056642632", "1115215543", "1960690660", "2027652572"]}]
|
distinct-subsequences
|
{
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>Given two strings s and t, return <i>the number of distinct</i> <b><i>subsequences</i></b><i> of </i>s<i> which equals </i>t.</p>\n\n<p>The test cases are generated so that the answer fits on a 32-bit signed integer.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = "rabbbit", t = "rabbit"\n<strong>Output:</strong> 3\n<strong>Explanation:</strong>\nAs shown below, there are 3 ways you can generate "rabbit" from s.\n<code><strong><u>rabb</u></strong>b<strong><u>it</u></strong></code>\n<code><strong><u>ra</u></strong>b<strong><u>bbit</u></strong></code>\n<code><strong><u>rab</u></strong>b<strong><u>bit</u></strong></code>\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = "babgbag", t = "bag"\n<strong>Output:</strong> 5\n<strong>Explanation:</strong>\nAs shown below, there are 5 ways you can generate "bag" from s.\n<code><strong><u>ba</u></strong>b<u><strong>g</strong></u>bag</code>\n<code><strong><u>ba</u></strong>bgba<strong><u>g</u></strong></code>\n<code><u><strong>b</strong></u>abgb<strong><u>ag</u></strong></code>\n<code>ba<u><strong>b</strong></u>gb<u><strong>ag</strong></u></code>\n<code>babg<strong><u>bag</u></strong></code></pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length, t.length <= 1000</code></li>\n\t<li><code>s</code> and <code>t</code> consist of English letters.</li>\n</ul>\n",
"difficulty": "Hard",
"questionFrontendId": "115",
"questionId": "115",
"questionTitle": "Distinct Subsequences",
"questionTitleSlug": "distinct-subsequences",
"similarQuestions": "[{\"title\": \"Number of Unique Good Subsequences\", \"titleSlug\": \"number-of-unique-good-subsequences\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]",
"stats": "{\"totalAccepted\": \"353.8K\", \"totalSubmission\": \"772.2K\", \"totalAcceptedRaw\": 353814, \"totalSubmissionRaw\": 772242, \"acRate\": \"45.8%\"}",
"topicTags": [
{
"name": "String",
"slug": "string"
},
{
"name": "Dynamic Programming",
"slug": "dynamic-programming"
}
]
}
}
}
|
115
|
Hard
|
[
"Given two strings s and t, return the number of distinct subsequences of s which equals t.\n\nThe test cases are generated so that the answer fits on a 32-bit signed integer.\n\n \nExample 1:\n\nInput: s = \"rabbbit\", t = \"rabbit\"\nOutput: 3\nExplanation:\nAs shown below, there are 3 ways you can generate \"rabbit\" from s.\nrabbbit\nrabbbit\nrabbbit\n\n\nExample 2:\n\nInput: s = \"babgbag\", t = \"bag\"\nOutput: 5\nExplanation:\nAs shown below, there are 5 ways you can generate \"bag\" from s.\nbabgbag\nbabgbag\nbabgbag\nbabgbag\nbabgbag\n\n \nConstraints:\n\n\n\t1 <= s.length, t.length <= 1000\n\ts and t consist of English letters.\n\n\n"
] |
[
{
"hash": 1869391220693607700,
"runtime": "36ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n @lru_cache(None)\n def dp(i,j):\n if i<j: return 0\n if j<0: return 1\n res = dp(i-1,j)\n if s[i]==t[j]: res += dp(i-1,j-1)\n return res\n return dp(len(s)-1, len(t)-1)\n "
},
{
"hash": 556544097565497100,
"runtime": "976ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n return self.recurse(s, t, 0, 0)\n \n @cache\n def recurse(self, s, t, i, j):\n if j >= len(t):\n return 1\n if i >= len(s):\n return 0\n chances = 0\n if s[i] == t[j]:\n chances += self.recurse(s, t, i+1, j+1)\n chances += self.recurse(s, t, i+1, j)\n return chances"
},
{
"hash": -7150592704632417000,
"runtime": "283ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n width = len(s)\n height = len(t)\n\n dp = [[0] * (width + 1) for _ in range(height + 1)]\n\n for i in range(height - 1, -1, -1):\n for j in range(width - 1, -1, -1):\n \n if t[i] == s[j]:\n if i == height - 1:\n dp[i + 1][j + 1] = 1\n \n dp[i][j] = dp[i][j + 1] + dp[i + 1][j + 1]\n\n else:\n dp[i][j] = dp[i][j + 1]\n \n return dp[0][0]"
},
{
"hash": -4839852261224012000,
"runtime": "630ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n rows, cols = len(s) + 1, len(t) +1\n dp = [[0]*cols for i in range(rows)]\n\n for i in range(rows):\n dp[i][cols-1] = 1\n \n\n for i in range(rows-2, -1, -1):\n for j in range(cols-2, -1, -1):\n if s[i] == t[j]:\n dp[i][j] = dp[i+1][j+1] + dp[i+1][j]\n else:\n dp[i][j] = dp[i+1][j]\n\n return dp[0][0] "
},
{
"hash": -8969210418178688000,
"runtime": "432ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n m, n = len(s), len(t)\n dp = [[0] * (n + 1) for _ in range(m + 1)]\n dp[0][0] = 1\n\n for i in range(1, n + 1):\n dp[0][i] = 0\n\n for i in range(1, m + 1):\n dp[i][0] = 1\n\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if s[i - 1] == t[j - 1]:\n dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]\n else:\n dp[i][j] = dp[i - 1][j]\n\n return dp[m][n]\n "
},
{
"hash": -2294293730739536600,
"runtime": "580ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n def helper(i, j):\n if i == len(s) or j == len(t):\n return 1 if j == len(t) else 0\n if (i, j) in memo: return memo[(i, j)]\n if s[i] == t[j]:memo[(i, j)] = helper(i+1, j) + helper(i+1, j+1)\n else: memo[(i, j)] = helper(i + 1, j)\n return memo[(i, j)]\n memo = {}\n return helper(0, 0)\n "
},
{
"hash": 7508004869407577000,
"runtime": "679ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n cache = {}\n\n def dfs(i, j):\n if j == len(t):\n return 1\n if i == len(s):\n return 0\n if (i,j) in cache:\n return cache[(i,j)]\n\n if s[i] == t[j]:\n cache[(i,j)] = dfs(i+1, j+1) + dfs(i+1, j)\n else:\n cache[(i,j)] = dfs(i+1, j)\n return cache[(i,j)]\n \n return dfs(0, 0)"
},
{
"hash": 7306066951910478000,
"runtime": "531ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n memo = {}\n def findDistinct(i, j):\n if j == len(t):\n return 1\n if i >= len(s) or j >= len(t):\n return 0\n if (i, j) in memo:\n return memo[(i, j)]\n distinctWays = 0\n if s[i] == t[j]:\n distinctWays += findDistinct(i + 1, j + 1) + findDistinct(i + 1, j)\n else:\n distinctWays += findDistinct(i + 1, j)\n memo[(i, j)] = distinctWays\n return distinctWays\n return findDistinct(0, 0)\n "
},
{
"hash": -974354836876339100,
"runtime": "828ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n dp = defaultdict(int)\n for i in range(-1, len(s)):\n dp[(i, -1)] = 1\n\n for i in range(len(s)):\n for j in range(len(t)):\n if s[i] == t[j]:\n dp[(i,j)] = dp[(i-1,j-1)] + dp[(i-1,j)]\n else:\n dp[(i,j)] = dp[(i-1,j)]\n #print(dp)\n return dp[(len(s)-1,len(t)-1)]"
},
{
"hash": -3677992322145964500,
"runtime": "85ms",
"solution": "# dp[i][j] = answer at i, j = no.of distinct subsequences of s[:i] which equals t[:j]\nclass Solution:\n def numDistinct(self, s: str, t: str) -> int:\n m, n = len(s), len(t)\n memo = [[0] * n for _ in range(m)]\n\n @cache\n def solve(i, j):\n # \"m - i < n - j\" means If the remaining portion of s is shorter than the remaining portion of t (m - i < n - j), it means there aren't enough characters left in s to form a subsequence that could match the rest of t. In such a case, it's impossible to proceed further with matching\n if i >= m or j >= n or m - i < n - j: # Base case: if pointers exceed respective lengths or not enough characters left in 's' to match 't'\n return 1 if j == n else 0 # only add 1 to final answer if full of string t is reached\n if memo[i][j] > 0: return memo[i][j]\n\n res = solve(i + 1, j) # whether s[i] & t[j] matched or not, still need to explore the scenario of moving s[i] ahead & keep t[j] the same\n if s[i] == t[j]:\n res += solve(i + 1, j + 1) # if s[i] & t[j] matched, we also need to explore the scenario of moving ahead for both s[i] & t[j]\n\n memo[i][j] = res\n return res\n\n return solve(0, 0)"
},
{
"hash": -5243053903945637000,
"runtime": "135ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str):\n n, m = len(s), len(t)\n dp = [1] + [0] * m\n for i in range(1, n + 1):\n for j in range(min(i, m), 0, -1):\n if s[i - 1] == t[j - 1]:\n dp[j] += dp[j - 1]\n return dp[m]"
},
{
"hash": -8923003622919381000,
"runtime": "382ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n # b a g\n # 1. 0. 0. 0\n # b. 1. 1. 0. 0\n # a. 1 1 1 0 \n # e 1. 1. 1. 0\n # g. 1. 1. 1 1\n # g 1. 1. 1. 2\n m, n = len(s), len(t)\n dp = [[0]* (n+1) for _ in range(m+1)]\n \n for i in range(m+1):\n dp[i][0] = 1\n\n for i in range(1, m+1):\n for j in range(1, n+1):\n if s[i-1] == t[j-1]:\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j]\n else:\n dp[i][j] = dp[i-1][j]\n \n return dp[-1][-1]\n "
},
{
"hash": 2842894680350588400,
"runtime": "877ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n # 2D DP\n m, n = len(s), len(t)\n cache = {}\n for i in range(m+1):\n cache[(i,n)] = 1\n # WHY ONLY N? no +1\n for j in range(n):\n cache[(m,j)] = 0\n for i in range(m-1, -1, -1):\n for j in range(n-1, -1, -1):\n if s[i] == t[j]:\n cache[(i,j)] = cache[(i+1,j+1)] + cache[(i+1,j)]\n else:\n cache[(i,j)] = cache[(i+1,j)]\n return cache[(0,0)]\n \n\n\n"
},
{
"hash": -8684649339668031000,
"runtime": "481ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n # cache = {}\n # def dp(i, j):\n # if (i, j) in cache:\n # return cache[(i, j)]\n # if j == len(t):\n # return 1\n # if i == len(s):\n # return 0\n # cache[(i, j)] = dp(i + 1, j)\n # if s[i] == t[j]:\n # cache[(i, j)] += dp(i+1, j+1)\n # return cache[(i, j)]\n # return dp(0,0)\n\n dp = [[0 for j in range(len(t) + 1)] for i in range(len(s) + 1)]\n for i in range(len(s) + 1):\n dp[i][len(t)] = 1\n for i in range(len(s) - 1, -1, -1):\n for j in range(len(t) - 1, -1, -1):\n dp[i][j] = dp[i+1][j]\n if s[i] == t[j]:\n dp[i][j] += dp[i+1][j+1]\n return dp[0][0]\n \n\n\n "
},
{
"hash": -7352808031598247000,
"runtime": "184ms",
"solution": "from functools import cache\nclass Solution:\n def numDistinct(self, s: str, t: str) -> int:\n M = len(s)\n N = len(t)\n\n if M == 0 or N == 0:\n return 0\n\n prev_dp = [0] * (N) + [1]\n\n for i in range(M-1,-1,-1):\n curr_dp = [0] * (N) + [1]\n for j in range(N-1,-1,-1):\n curr_dp[j] = prev_dp[j+1] + prev_dp[j] if s[i] == t[j] else prev_dp[j]\n prev_dp = curr_dp\n \n return prev_dp[0]\n\n #@cache\n #def dp(i,j):\n # if j == N:\n # return 1\n\n # if i == M:\n # return 0\n\n # return dp(i+1,j+1) + dp(i+1,j) if s[i] == t[j] else dp(i+1,j)\n\n\n #return dp(0,0)"
},
{
"hash": 2049492321081134600,
"runtime": "333ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n # dp[i][j]: subsequences of s[:i] which equals t[:j]\n # dp[i][j] = dp[i-1][j-1] + dp[i-1][j] // if s[i-1] == t[j-1]\n # dp[i][j] = dp[i-1][j] // if s[i-1] != t[j-1]\n m, n = len(s), len(t)\n dp = [[0 for _ in range(n+1)] for _ in range(m+1)]\n\n for i in range(m+1):\n dp[i][0] = 1\n\n for i in range(1, m+1):\n for j in range(1, n+1):\n if s[i-1] == t[j-1]:\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j]\n else:\n dp[i][j] = dp[i-1][j]\n\n return dp[-1][-1]"
},
{
"hash": -3243460681806075000,
"runtime": "778ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n cache = {}\n\n def dfs(i, j):\n if j == len(t):\n return 1\n if i == len(s):\n return 0\n if (i, j) in cache:\n return cache[(i, j)]\n\n if s[i] == t[j]:\n cache[(i, j)] = dfs(i + 1, j + 1) + dfs(i + 1, j)\n else:\n cache[(i, j)] = dfs(i + 1, j)\n return cache[(i, j)]\n return dfs(0, 0) "
},
{
"hash": -279419309653275100,
"runtime": "729ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n cache = {}\n def dfs(i, j):\n if j == len(t):\n return 1\n if i == len(s):\n return 0\n if (i, j) in cache:\n return cache[(i,j)]\n if s[i] != t[j]:\n cache[(i,j)] = dfs(i+1, j)\n else:\n cache[(i,j)] = dfs(i+1, j) + dfs(i+1, j+1)\n \n return cache[(i, j)]\n\n return dfs(0, 0)"
},
{
"hash": 105503748805375470,
"runtime": "729ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n cache = {}\n\n def dfs(i,j):\n if j == len(t):\n return 1 \n elif i >= len(s):\n return 0\n\n if (i,j) in cache:\n return cache[(i,j)]\n \n if s[i] == t[j]:\n cache[(i,j)] = dfs(i+1,j+1) + dfs(i+1,j)\n else:\n cache[(i,j)] = dfs(i+1,j)\n \n return cache[(i,j)]\n \n return dfs(0,0)\n "
},
{
"hash": 2054347272361440300,
"runtime": "234ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n N, M = len(s), len(t)\n dp = [[0] * M for _ in range(N)]\n for i, c in enumerate(s):\n for j, x in enumerate(t):\n if j > i:\n continue\n upper = dp[i - 1][j] if i > 0 else 0\n left = dp[i][j - 1] if j > 0 else 1\n ul = dp[i - 1][j - 1] if j > 0 and i > 0 else 1\n if c == x:\n dp[i][j] = ul + upper\n else:\n dp[i][j] = upper\n # print(i, j, dp[i][j])\n # print(dp)\n return dp[-1][-1]"
},
{
"hash": 1953115908310993700,
"runtime": "877ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n cache = {}\n\n for i in range(len(s) + 1):\n cache[(i, len(t))] = 1\n for j in range(len(t)):\n cache[(len(s), j)] = 0\n\n for i in range(len(s) - 1, -1, -1):\n for j in range(len(t) - 1, -1, -1):\n if s[i] == t[j]:\n cache[(i, j)] = cache[(i + 1, j + 1)] + cache[(i + 1, j)]\n else:\n cache[(i, j)] = cache[(i + 1, j)]\n return cache[(0, 0)]"
},
{
"hash": 698296362266152200,
"runtime": "481ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n \n @lru_cache(None)\n def dfs(s_index, t_index):\n if t_index == len(t):\n return 1\n\n if s_index == len(s):\n return 0\n\n count = dfs(s_index + 1, t_index)\n if s[s_index] == t[t_index]:\n count += dfs(s_index + 1, t_index + 1)\n\n return count\n return dfs(0, 0)"
},
{
"hash": -1607357415221802500,
"runtime": "184ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n \n @cache\n def helper(sIdx: int, tIdx: int) -> int:\n if tIdx == len(t):\n return 1\n\n result = 0\n for i in range(sIdx, len(s)):\n if s[i] == t[tIdx] and len(s) - i >= len(t) - tIdx:\n result += helper(i + 1, tIdx + 1)\n return result\n\n return helper(0, 0)"
},
{
"hash": 8498807121087751000,
"runtime": "778ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n mem = defaultdict()\n return self.numDistinctHelp(s, 0, t, 0, mem)\n\n\n def numDistinctHelp(self, s, i, t, j, mem):\n if j == len(t):\n return 1\n if i == len(s):\n return 0\n\n if (i, j) in mem:\n return mem[(i, j)]\n\n if s[i] != t[j]:\n return self.numDistinctHelp(s, i+1, t, j, mem)\n if s[i] == t[j]:\n # take it from s\n a = self.numDistinctHelp(s, i+1, t, j+1, mem)\n # skip it in s\n b = self.numDistinctHelp(s, i+1, t, j, mem)\n sum = a+b\n mem[(i, j)] = sum\n return sum"
},
{
"hash": -4346195533800633000,
"runtime": "927ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n\n # Neetcode solution\n\n dp = {}\n\n def dfs(s_index, t_index):\n\n if t_index == len(t):\n return 1\n\n if s_index == len(s):\n return 0\n\n if (s_index, t_index) in dp:\n return dp[(s_index, t_index)]\n\n dp[(s_index, t_index)] = 0\n\n if s[s_index] == t[t_index]:\n dp[(s_index, t_index)] += dfs(s_index+1, t_index+1)\n\n dp[(s_index, t_index)] += dfs(s_index+1, t_index)\n\n return dp[(s_index, t_index)]\n\n return dfs(0,0)\n\n\n\n"
},
{
"hash": 5588259687366920000,
"runtime": "630ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n \n dp = [[0] * (len(t)+1) for _ in range(len(s) + 1)]\n\n for i in range(len(dp)):\n dp[i][0] = 1\n \n for i in range(1, len(dp)):\n for j in range(1, len(dp[0])):\n if s[i-1] == t[j-1]:\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j]\n else:\n dp[i][j] = dp[i-1][j]\n \n return dp[len(s)][len(t)]"
},
{
"hash": 1379378371899152100,
"runtime": "976ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n n1, n2 = len(s), len(t)\n\n @functools.cache\n def helper(i,j):\n if i>=n1:\n return int(j>=n2)\n match = (j<n2 and s[i]==t[j])\n total = helper(i+1, j)\n if match:\n total+=helper(i+1, j+1) \n return total\n return helper(0,0)\n "
},
{
"hash": -7334161435866905000,
"runtime": "283ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n m, n = len(s), len(t)\n dp = [[0] * (n+1) for _ in range(m+1)]\n for i in range(0,m+1):\n dp[i][0] = 1\n for i in range(1, m+1):\n for j in range(1, n+1):\n if s[i-1] == t[j-1]:\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j]\n else:\n dp[i][j] = dp[i-1][j]\n return dp[-1][-1]"
},
{
"hash": 460518810727037800,
"runtime": "432ms",
"solution": "class Solution:\n\n def check(self, s: str, t: str, i: int, j: int, dp: List[List[int]], visited: List[List[bool]]) -> int:\n if j >= len(t):\n return 1\n \n if i >= len(s):\n return 1 if j >= len(t) else 0\n \n if visited[i][j] == True:\n return dp[i][j]\n \n visited[i][j] = True\n dp[i][j] += self.check(s, t, i + 1, j, dp, visited)\n if s[i] == t[j]:\n dp[i][j] += self.check(s, t, i + 1, j + 1, dp, visited)\n \n return dp[i][j]\n \n\n def numDistinct(self, s: str, t: str) -> int:\n m, n = len(s), len(t)\n dp = [[0 for j in range(n)] for i in range(m)]\n visited = [[False for j in range(n)] for i in range(m)]\n return self.check(s, t, 0, 0, dp, visited)"
},
{
"hash": 8721058326217449000,
"runtime": "828ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n # make sure len(s) > len(t)\n mem = {}\n def dfs(i, j):\n if (i, j) in mem:\n return mem[(i, j)]\n res = 0\n if j == len(t): # find all t\n return 1\n if i >= len(s): # didn't find all t\n return 0\n if s[i] == t[j]:\n res += dfs(i + 1, j + 1)\n res += dfs(i + 1, j)\n mem[(i, j)] = res\n return res\n return dfs(0, 0)\n "
}
] |
class Solution(object):
def numDistinct(self, s, t):
"""
:type s: str
:type t: str
:rtype: int
"""
|
import random
import string
def generate_test_case():
len_s = random.randint(1, 1000)
len_t = random.randint(1, len_s)
s = ''.join(random.choices(string.ascii_lowercase, k = len_s))
t = ''.join(random.choices(s, k = len_t))
return s, t
|
def convert_online(case):
return case
|
def convert_offline(case):
return case
|
def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False
|
numDistinct
|
[{"input": ["rabbbit", "rabbit"], "expected": 3}, {"input": ["babgbag", "bag"], "expected": 5}, {"input": ["rinnqntsvlekptulnzngbjkkaulvqututxrjaoshcnxwkndhglwlraazkcagureurlzfdmhcmmhccixaupkuiblgzfhjxjdgdcewrozlxyttvjfpvxrfrnbarmdwkkwhltzslmtgscbdjmrnuiwbvupwvujvoakzqnqhwctjqzhcjtftcsjqwmhujbbuueyjoxfosyxqahcpntfatrlmhebayprmtfygqrclnkjthybhjrgzmpwmvpqkvhmbvqilxqdgnhmbinirscaghvxnnxcajhavlakasyznijdasgscftqfkimwbfnzpmaxdjgtzrpefpqrluahgxzbismakqzlzkjricrlqirllzhqpvjamwnfstbhqkotsjzzwwscyewxdrafjtpy", "vmgeqjbigwwqimibwxlcpligjaqbtzjjojmqksrfqshwryavrzhxncndtkhazcnjqhjwlrlwjwzhxpgikjzj"], "expected": 0}, {"input": ["cwwfyucmdipwajiryxwmsmualpkngmydyjvbzcnhqkzorbogshujhvruzojcowbkaqtbalwtoptthuswxfqkcpurjnvdhcultpudztxrihfqwsmtpovniktzvzpaoayknbvhlmlcqnjydtirrbboxrvebvcohmspwdutevdcgziwhnlxcmhfaomcvqhonrtjcsvynxtvttmewrezbjhdbdctluvtyuyejmqbavyjseedqdprrtbyvbvymltiqwnvhyqiqkeacgyzqwyueckglgapparlqmghjdvkknqwwhhjcwgjejvbwdgzgqtcnzjkvkiziurunmakjiynwcppkmrgoggbkqvuyyddrginsjnywxlvmxprvxfhtkjwpbjlddwaieytusytyombfnwj", "vnjhumavkvyjwmuwcnmwufyqcpzjmdvjknduuiyejjwbwddnnxlfzwyzogrhtfnzeodfbnsrghbwtygzcbwpvxnwmfnzdrdkoyglnpymeyznweqwghvxqbzmpcvmjwrtawhvavlcgbzkflpijyeprcdiuysywzsyghtwqavzhftuvc"], "expected": 0}, {"input": ["suduhomscotedqrypjehogxgqpotlvcpabzgrdfllopicxgyjpdzwqsjkvkpxdckwjbtipujhvpnhfqdlurmwhqappjlowvdvvysgawrzrhmdheqwrneibnzoiqmexnjxralbxpidymkdnofvpxvnwomnsekrvwnarfinisljcczwwysrdehpkbiutrwbuggtaeqojieqhtktnmlrrdyydbibpoyjnvhuamunqnatecdilubtmcyfvsnjmnfuvtzkmqwgcedhkqawjxlerbdfkkzmnmjfmsapdndnaxkrqgnpmtxbzumherewfqndaekpmzlsedihgcynumbdjbthusaesohvqlivkrsmtfjpvyxnhizsqerpbspzeawpahhvebfgrdztdkzbrcijlqxpmirsjutkhhwppfdshxncqcjjoenaqofdjffttknqgkceepxlonxptubegvqrjwetpftanjtrjgtbcuwdwgfvhdcgarxpamhkzaptrjrspikpqhtwmniatxctfqkuaxpmjcupayfxisfdxfhjzuvjgtktskqoduonpbakezvltdlggwnugrnpmkcyhhqtkcekapqfqjawucll", "pcspmtchenwayhkeafpttyecjttnzaljofwkkjefpajtttbkwlvsoqnsmtnpvocpspafhkmeyotyqpoljhcpgpjemjunptnjcveqyojhddfrdpnkanljeqgfvebtmaxpfuddadcrndvteesgwegvqkoiwivxaqosoviuhjzaibbdspckrnjzxkunxhsnksvcjgrggqhxqnalvhbpyrkxgafqdmvotvndkcvlrghhqsmwvttnvttffpvogfkprkglhorraepckczbtteiagchbpsqkjisxezabdnnuemkhnerp"], "expected": 0}, {"input": ["nxmadgakpthbixptfvspibxfvtajfigoorcadfntlazvdxexnypytzoiofqowmetckercbxvrjmemjwrsvpgvqggfdpoorxcdzezsbrawvphbfbpqddfxerhrcmzkvvsvevzpvbxtkdurssnqenupiubleecgainbhpfdjbdigoxxenchgyjktsrpsgpjwzpsoktzjchysptukbzpbjnrqfmthqzyyhawaagbqhbwkvdqkkymhvnydbpqzwjoavxkozgownfpeujpsjcnzvpdfpsybelbfdwshphunmmvnccgncsqckewvxwgbvudmeoitbmrbozxqbsbptujjabmbcmydttmehdksqifpntbgqghyrgenjjkxcddaxiiqnzhukcgtnkdrovyfzwaalvopujjrgvwbmrmxcptfcpwehyzejuolqvujokktesypxnsrxuhqungfhaoyvtuamllweuacwvwcalyfwwugvtejuezglkwgtwjmhzvfxxvbjywxrveggcjbrocypefnksspbjhcbzvnsumjbocmyxunerghkmrneyervjqhy", "mwoscwtcjphwdfjeefckdezrsnbbbrepqsrhajoakhjamtzbeohpgvvwpfimydjrjfcvgagnpsptibotpolkskkjqsubenpgczivaqoyjnsvbsndflfumjrabjnpemmxawsuktpsixcbbvnaxajzyvfbqjwjknqvujjvzepvvqltreukmaqjqclqhhktpnahwdaqkenetrf"], "expected": 0}, {"input": ["rwrtfqaiucgdcxbikoinivigvtuhzoyfaecqocnrrsluhtxipysdvogsgyuxdvmtlmobppnvkqpstjjcfqwqaqdrwyzebnqpaitvuphigelxuimalvajxiewaxynncozzohxbhbjuwgwurahbhejcfzexekajs", "bjmbenpoaxhqizauwhqmuqcxtqbqrrmfpqvvnqsprwtihhoxbainp"], "expected": 0}, {"input": ["webkfvjefrexaoepqajjvxvoeubhyjkewtfmejxdkqzljlzwqtkrzgltzkdxfcqsqswjutbyijppspwmmlkaoppqisesnskeyfgdmwtyftamyldrbmrqjekvhqnumejibsyjyubmobicfqyiozdilccnhouiodakaspqykcyyigjmtwprgiffpiirwjpikkmrdkcdkduydwuvnjvsqjsiujnqsbzihgtfovlaivoczqhzuqbrafxsfsjqaziliakzuompfifvlegnaemsyizgkvuyyvrgvwyfhugxpfcsimsvhetduwgqzspdpbpohtpwamadflbvexcaqjfmvqngzmqyeplboypdvpluptxvsmraihalczydkgbpjmoazzdmjawsppoolzsqvorpsrjpsmhqnnqxymtprdwsqelduzglcbzjkvmrwvwkscjrnyycvodqiftvnsvwodgldipfoepwilbjurcpbvwnvdtysghcodzglvuwiqoszqgggdhlpccfqzkozndlddlhthncucisydssemycuztpgdarszcdgrwmxygavczs", "wwlelryumwhvdrgjwszwkkkknoetbqvfkswjevlhmgtqyepcdfkwengidiozityiqrwhbxdckocqsilmvtafbkfyfmspviiybuiivoszdtdszluakalzglsjpjpylzipjledzsodhfyilfkzaztkxoazwudwvljwyqmcopwypvidlhgzglpzspzueiqeksytfqyonkkjiqemldbvfybajgmcbyyugyctuklpidowvjdyltyufhgowseqfowpmymqpjilsvczmbzsvgywfjfvmvlykekicbogbylymwfcrvlnlvqpxpmyaslzhpvrpqozdqrbdroiulqzydqglhngqgwrddxqlsmjloyvmtiqaqlucpcpsttgyrzgevpfxftyzhaontedquitmjhvyegeygvfemosqwgfjejakuwiwlutmhzzppxwtzqovixvagsvfgdelryvhgfqdxdyipmhvlkykzageviqewsctidpgmxiakqqnmezylspyeyyeizjxsqlwsyhlkrfqikcsszcdazytuihjvsbopudngazsdsdsopsjj"], "expected": 0}, {"input": ["xwqebsivrjtdpoyjhqngkanrcjepbyfvljgxqgqxkxqpktbxplsjdbgmdqyjgveqqsfmwnjztgpokpvmnchoxqeyspgluwddvhpblluklgmkcepjvfddcerdbplcyhglaiwjlhpuywabwwuwedpqudjgmrercvjhyvdqzfcprjrusfgdpmswzahzvnrqrmpyskquvrfsqzlbchzuzsvhcgeuthwhxtgptqxryzpyvbpyoadsorveapizlwwnhgvkewvtpfugghlgmeiffatmrtfzivnlegxiingvhejfgmkpartijfluqefiumepipuffwusjdujobttspvohqcmgfmgeshmacsasuigzqqbbigdxkfvtiawnostffmnneytqrxkglmruwmhfzqrxabmphuvxkmeqcscghtlzsctdefhnghjpxkhgtscnrcsevtnekxxuvelphznxqvlvspxjkmugvhvxniqulvzkfkownnlgmmumwqpgktonadsaxteqxlervkmhuutmchflcxgfdpmmfirljqbiawppsbngppsvisjrowknftyilvpvqrxtjmkkyppbyzskknjcdkpaxiqworhbxhjwivdnmiuquabbhzaf", "sjtdpabtzrmhhspgsjdjvptnhduxelxtwhjmptpliemplwrhuvznhptexfppgyrfardztsqbwpiaqmhpuxoazmhegzkcuquwhnguddvavupjcgthfgxlztqspfhbckvxuirjrienujwxvirksgbsyjtfwpbueunkmbshzqvfxullsmximfmpnkrbplzghsjkbgesgzgfsvtqqjkbynuwparmjsgkiewvzpiuptwkkdlatdbzdgltxmsdpdxutfvkrxkkqjunsjiisdtcihzeppfzgdhhctenyqrkizefpwbcbhqvjtpjkmbofeevrveekkukdusfzcaygdzqcgvnpgunpnkrnnsvfxrvipndhcdcyugqwplutkygsmyrvqlzprlgaewgzpbjm"], "expected": 0}, {"input": ["heuplazgbfpqqmrxbaazxfdsxhmlgftgahatabekdazkhfvsxbywnivcjyfutyejactitkcrhspxtkwowwbkwljjajhzdosxzpvkeryruyqechuvbvptgigsezvlqfhmagrymzmddpyxpzcidssqj", "xayievbhhwkgahaoppzzpaxwswkuqpuwqyygtgmatejsxjsoulmyswxpgxjynffubdcxmhsmxgcwajsqbyj"], "expected": 0}, {"input": ["cddmeudddpiahdscajhoeydsfpcgctykgrjkesscwzofttegrkoithpujmbhtrzxvjytachgaonewikztgppxflagahakcyxzgilipriwzptqqogooprllqlyhqxbcyzozvenhagdydozhqporfdosjxdiyftriyqpvvjhbpeawhtyrtifbgckicyedlsqvkpgtlptfpdofwoqfqzeeletgetkkjlzoljehsututbolhzugsbukwvjmyobzapohjlmjlwkfrwnbgarsjwgwwqdbtxrnogsvjliaauokahutuyzvaskcmqazlaufubzpdphzkulnop", "kpxizkncatqwjkhtgovgtuptscsjicvpzpgoovtwgzvzzkzqvhuctdktlcgwhdgtrddjnzzetoajsllvahhqdworeylqupyqdlsgzjzthfhfggzxcsitrkqvwazststofailulybvblhtgackwebloyxherbhtuavdgbvqtfuyooldckdmhdntrvjzgttjhikhuhtalpaozqndtjfdtpigfaqtoiegiuymlhrtzkriiijqkgoyuadkuftiuooduvuhcktbadtgkogfugjqzuctqotpgzotkiyzwhj"], "expected": 0}, {"input": ["hzdxgasrnxdemzdfhejltwurvnjbawiymsnmecuokltsathmeuqutibhwunmeyuahhlnssmkkxygsxxiizztinxdeggmmzdxbcpjpdhvqzxnimohvefzkedoqwgyppbztfxhznesfnecmmfmeiibolvnoqofvfewgfhffpkvsspxierkruglefhsemkmtghsyvalzwpgoughowteylpqqcbewcreznsihnbkwysqorpjrdiwazkqnelcgnaymgflthdkiovnfsuvitlwwqutpqlzezhemhfvbtnca", "dikwteeapdjwqywxnezytutylfheozvkqmpmemzalsvggebwiuzwenvgvqefyekchhzedelpxciuinzmqkqtyofnirlmkmvtqgzcnknzqmktnedsfeiqmohittvvpcmtzwwbnmhthqbsprtiymhnbgslstomspekfsmxqdnzpbbteyklpziznmainsevtnmpioaehumqiexsfgqzqsyzzn"], "expected": 0}, {"input": ["zehnonroiyhdcrkgyuebmyggsvnbtwvfodmsnktuuwnhcfsjeyacjokgpaqsbnfghidhmpxolajtxvobpoitepxnmzpaahwcxjcadimrrkariqzhaovziwghtuzhmtpskypuchoapmlplrccjlposadbmjpaxybmzcdxbgkirpazdifzqoutphtcbcqvmfkkrtpsbskqydaajfoaseopddmzdieottfhozlcdbeeydokobwrwehjbqsqqzccbtkbbzbuozimcwkmapuppdre", "khofzivapcdzvsschdkpdltvbxqwwqswudkbjodjzfqrwbzddigwgamvqzdalrdoynpnawzgxglxqdrazyxbcxcomockotpeyaalsljsbboekfaecrqerbkyedebouvqozsveubrcgakpfccfeiopzoedpdidibysygdtkshrimbyztreidbgffzjzpcocaiiaaxzpzzlbpfndoawpaqkctavhtgkttaso"], "expected": 0}, {"input": ["glqnlbqbojuylnuwfntfwqbrpuvycxhdlxcvfnnfonhbdpvsyldtjgwlxxonspoyrzsgckhfynkqhpimcsajiidzsfmevcrpiaywtyfxpbiclrwpqqghhonxgvtwpnjfuhzyhvgwlijtsvxnmqcnetxcjcmptrylfdvpbslemvlalowskqknutefodjsvbxfgavrauzkidaihaliubdzineogbsaybiwvtqsxgjfekzippveisqbgpyankompetvqlnxqwtlqhlgabhnjktmayubzpmfmktztrugxyvbkmnyzgssjummppvgngqkwonzcxmwexotdhrzfmtigulmhsorfnfhmsjlhfbahdwwrtonrtlgsdggsnwqmsrtdbqqncfssqbkrkqafkozlevxmrkvmzajxklfjtspcluuyrogalntarclksqyynbfuyifqydzkuelgalrexpswksonwfqwelocoqxswae", "hngofkhlsgisrykpqpomojepqxyhwslvlpiowuiyfuwdvgexmbuvmniraqcopxpphuvyinnhorslwgglsc"], "expected": 0}, {"input": ["wqciazzupnxchpcywacrxlhjzsorhjjqcvyeknzltgiojuhjnsueeccbsnitkaijbpublneyqccgsvdkcyizdmlmovjddjqsgunmuxkktyxysxrvqmvanmrliqytyahveveirumkzmaangfqccclrvedjkqxlpoxxbsiiymdnifxpnfzhjlqvyqsjjduhhwuyyghlvimdssvldqwvqsoqyyufhnehhhvbyitfhjahxuzxmrzmwjcgdgcjxlxinxddvsviryssutpbzgtihpyjcoacwwqvgrohzcyrfremvgrhkbxqmaktvkanvelgxatbnwwisahzapsmtwyxupuegydkvnygxphplksnnqcbcoslrpggitmggaklposfznhqrlvrzrbmpgkxwvasoxouieheufpxosemfamlzpsolrvxbfdsraphzzxymrhbgweutslmpszkwfdlwdcaipjjfdqvyjzutayyxkznfgppgmmmqrdwfmikvbkdglfoulbvkepumymcuulhbjbsasjtebfwrzfxtjolbuqukfiwjzveyfvapqevqqlnaurscbflwujofisxzljijvttmkqpvjguotvqciejnwpzciezjuywthrfcfncirmkmoncmcpf", "gkpqjneruzxpsuzdgqxjlfsxjufsvpfmvsmptjyliweslelpvwnnsmvvyawvvzdmipehtyuhjqfuucbvvqipkqnmhyxzclisunjvjdalmtnkygkhckhxkvlexknqqsomsbwmrchfzunnxmroebvjwnqdpsoqp"], "expected": 0}, {"input": ["pxruxymthkahwvvxxokdnycljichskkfvdidacbpndjtpjcbgyyjprmtmrjwwyarafjdnhnwockcdxhjfbliqfslcqpstcbhrdqnrmmiwntitlpqqvkltmjjxqpvrobvwkfmtxivghgftsphomwbhelybopuplwsrbwdmwkdmzuwhrwlveaxukqaewteljhvowoahlbniqmefvshblmzlgodyqfnyndnlmxpkgdqwrnfbftfhekabvlakjgmdnalsgdrudojheoxlqozczzlgynvszxcklihhijniskwealdzhkplobwozfgcnnjudqizyatrqgfalntemxiceqcup", "sjvhcgsiiggrbpbdernhiccknvsjtjagczhdamiwkylhpmolncradnbdopmklkirozhtjmtpehhprodorcngxtpwbrndkxvfdhiboakwfgmcntenzpjkwydgilkhgxiwjvauhkclllrkyqdelbllfunenwffcfrawfzxoxhlltkebxaywjmaqxflnhcmqtmqozmvgobwwovivmwfymbttlzhatmofrp"], "expected": 0}, {"input": ["zojjoqoebmhhsbcpyfjwtxrlnymavecsxvpewxjryunvdduzppyndthbdpctwatqnvoaqkrnamqcwuafcorfduyfqnvthkfsrjdgemzsqltruwdrfmwfdxlukihwzqdlxlwlelwkiwxmxrbxygonbnujutpcvyintnlhvijzmhhngwmajgllqzuhtsorqkdjuxryblccrijlspwkybkopdlmpgeizuvifcwwxlcgmkxaydnujdcxvxvzfojhsnjwjrsnefvibtmmxlskkkolfsmyboceardsaiqmzkvodknyaitnsbsnjkztjfforedravjslngssuceayxnnmudmmgsjmsgvdpthbiwgfykrlnqpgypqvydsmbadrhwjtanrxjkrmcicbirfwylawjxxfltdshgyhtgoidrotdolywbpoklzewlyykwfbvbzeybyhtpbqmhwivummspkkjxthfkpreakczdslfmwxtqkxwnaarpqqukouammakxlvbfwiqybmljaydhnuracvunmqsfngrtctpmajopsfgpphsgusbrvautysgprsivykwaccpactjbe", "efzykyjdvbygborokyysamyybsyyllbvksfrsdhndsmmhlootcfnyvomdhdpsdwtriqpdrpkmnmtscloyfefzmikcaqxbpptslkuwkssxbncyapajcfroiihkossumwaqfnccemqiwswnrdgotrtybkxjircpqpxsjoifggmsreglnctkqjtkrjbddmrlqayvzckautzvdxppzkwnigbkbmfwxybakrfrrrtewvjnlpxvxmhsvlduzmfxphrmdlllwhaltwnwdfyvjlyrbammwdtlcipzfokmhyftbrarzlrmmmymrnssfchsixwoplaephudggsjfaazlxpmtqwurjucakmzhyurhcgliswrytsougsfbhuvbrctjmenvxvgvnubrqbmdarxnvyynljwmwdducamshcoxblutnkspmdfawpparupyarbpyefpeigdmwccyrptuvfrwwavxryrfxubrrydmatsylpdrevyzxtonhchfldmctafxxxejxpcrghupavfgmuqvxylmbcdmcmvlrjesnbvhzbcpsksyushdplcyleyucyxjlawpat"], "expected": 0}, {"input": ["wdriugtuoeemtngwvcmxpslamalxkmpdyjwigulyqptpdbelpsfhouhzctjotqltgjdvzayblrtetszpdkqpchllvoehtnbxhyziabhqcuwbzmcjqxsfqkubdalfosngrtdfuiaapcnpjvnekyrktaifiawlkwpznzpymzwrwymiwqgvjuqueugvvwjxhmshmieruhxmxesmmucgpbhfzjifwaflqqbfveabgqpwtmwgcxblpgawjkdmqenurjdzkabunllzkkoeemtitiqvowoqeytmxyogzwnuowdaatjsvvfkjsfozqgrwhdseepehicuxhyqeihhhsckdlhverudvhriiznvbtwhsuthaudflzdasuryzcniqikinuxorpnbzbrjodnwsqogmpguontypdzmialtugtfsgelgcfyqqtmydqhxlefsblgkcvtayozothhzvpqedlsufldmmiwuzrocgafddgcozxneczwntvzyhetlajvwrtcrcdmimpsrgeutmoeidviecaehjxkumhkcdsctjueesutjbizvgjceiiawbvnvrwxoqujnhbvciaijdkydhkkzugcbyldgibkgamynhltykswdqvsssiejhosduzvwefplorxmdrtxkxsywesiymovxzfsrqsbnfmcycqumqeqjkpybkwkinajweklgrlzyxtlzvouwpqurkfeknvmgzd", "tczdvlxzmpptvvbojrjufwslcdwwucjuzdpcwqeoroztgdfebgcomxucynpskpckpunbjzzcjjcdnccozkuizjipspjuzmmsduvtwceimusfrihjzvnyisluitbkujkwbiqmpudndjkddfaaqkcxiafawmikzbonhutlkdckhcldtzoutsqoywqjdrdqzkpju"], "expected": 0}, {"input": ["uiugbmtcgndwbrzhsycmisczxlbrbpyuzztvfekscyjtssurfvbvwzflupbyemmjqeckxrctzywvixbbqusgphyvnipmgwbzidmssuoefjxpqgisotlaemsklraetjsvljbsibapchphktugeyojeqtedpmcxybedziavwzahcnrvczrkwfydmfbdqyilmjscszmzwnhtrlzqqxqmwrkqnxcgytnoxstitbynofcpekuaufshgnjlchhmqjfygvfdvxpbvyuzgybxgysixkuwuidyixagtvhoppsagykatoxewpszbmoybqrcinnmcmzauzawasddyuhpygmtexbfsaojzeitwioohzludsllbxndvuhtkzdoceneygckeauywptyxnbczcwmmaeaowkrsxkxxpnstmecmtoiwzzkitxdzioxdtinsznmjewbwzzjxrfyrpunbdqmkjqtxuxnbpcgiquwyfxaekxjwysriajasfqswcnjhsdbimdwglwdsuhscwckywqqvtcnqifzunsjtuqyfctqteevysxaesjljnijbpckvdurkhcprrkmrmgjhiataajcvnhjydiobfczoxynquumspvojzmbmtizwphcajpyvzrjgnuwtxhuqnmuguydcomzinjlnbpcivvkinrqxprtjvuiumgsosventnefepxethzuadcyitpxtkudcysmwbcoqsbshrvvwqzomkgtzigscoegch", "avxagbnsvnokusriayieradcxvjetcnjyzhqveoyhubzkrerqetkgnanbdquunpzewkjjeflaaucnuyxyutwbuefdwmrzloavmthmnidlwpoqejcsaurzsnekjaeixrfdqitmpqtmwsczvwhdtzytbwjveyeizprjntsgomqswmpkfirrbyngebmwxitkhueehycztpjrarihanywbsmwemirbwewnuzwptzbqcctvzdlfmfpnsqsmkimsvlwoaavvrjmlsqztovyomanrmihezhpmzgscakikerwdyceymuxrmvoqmettemsjuswpukjfbadkcuszkiwcq"], "expected": 0}, {"input": ["oxntvslsigqcvvrxnzdjqxlvjzsflijrsiqxilfuxyppfekfwwudazulygkgsddfsyieomfkcjubnmhiocrnedxfyjhadthassiuckajdnmngstlcxuhyeqoliuumnyspfubojlljswptuuveyrzapntuxfoekurjlbjwbnsfyjjwnyxtspeydzzblxoecqnhwfjcsrkghtxmzyjhmmpqrtqbvnchitptkgnzxbculdpckfpevekxamjioxmxiokyeradpphfryrytsbtzgcibmjsxyozmgepsjrvxfvwgcqkpcmjycyoupmzijmphvytbgnvvdwmzwhslkowxidlvstyrptsrusbxsvwltlholqinejnpefplxwgfrafeuzkhahatbdfyncpaaervlxdlcbivysckljmhobrbicjpiarfcavxqgyfozruekkzgeivmdjdgihcciflmjvmpjjlgffxdmfzvysrubwdjjbasyrloysvxpojaurmyptcxsnyvrvxmdxlzpkbzpsdzgdcmfgezmimvmwfyswjcjbdqjewmmdltbhciabozkcidgqdbhonuludqlgnokxfgnbexkjhwxlsnxkffrkcwqlmpmspsewfrhyrwmijrsfnydjlzkddsfqhrkiieiazcgrrpxvlunvckaaufqjplxfyqdujhqxydsrthfxjxcclmqsspjorfuwnevnrattziuqcaxmccbkfyzrxhcvhygforetsutuvsfuoojdxhbkkzzdrxomcfzbbkawfdjohqiarmbwdqwudoqweveigzuiessjhiogzbmpvvdvfdegtoskudoznllopbyupivrhguuobaxletktqmrpmtxfwvhxewglyoahsnbyhuxcwpispamndtqvxsvilmosjxqzukckyixyrrgivwlwgxbzzotqxkvjqovfnkaedowlafufjzsbvfhilwjsjsncjsywdjwnfwhyvgib", "wamhyrfhzmillxhmlyvldilquyymmsnyvbxdavvcqlblkxhszpqkymkmvshycpmizamkfmjcchlmsfdyjbdoefrvufsicaffayhxexddcomxdjlrszinjwobddfnxfsjovyoetffreutytjmtpvfnaxqzsdpvoijerivwuwbieehmmwisdoyqbdvoijndzskirbffhgiolrspbbsdpuljzzevauxdwdebfmiiroxlszyfjqczjruwjvwgjnkvvyucizslhobkhmpsvtpqdmaabkjfyclynxgsshhoywshsijxvirgjzdzpplmhqimzorymc"], "expected": 0}, {"input": ["idajcskgsnrtjsuyyercrolhlujowxwgusjvnhpurmkqmpfnlrldhciyltnikgueztoozklowbayqczkymlorsdtvdohhgoblrwktomdcmacwekzzjencrzgonfolhmwwbxqbunlyadrghoualbdhdpkwancqtagvwjxdbhssfcpkpairoaohtxlacmzaqofmgvbkxtymiynltrciyfxxemgtigqfuygkshzmumfjbmmckdkrpecppggbwfrkyuucuewezkuzvtwquizjledkdttluogveynatfawefgvuwjxxsytjcxz", "slmtkgricieskmluauhwqbdgroqlxymwjneoifhkpmtwvcruak"], "expected": 0}, {"input": ["bocxtgjkmdxplbykdhegklbbyuufzhpxnwbqgikbkzbvjpzscfybcsrdlunjqabxfhbstkczfvknqhkjfweusxbuizwnrsvlgpbrchghlxedicwjnnwphtgqubvdanjfuixtfjdvxmgldcvfytedjkrcgwbcrwkclmxozhkbrjbffdzzionkgjlkhiuibpexoaemrykptyftejhhdqgdlwvryjmyoqdblkktrabeigxkgsmotcumdjejbkpbejkxupvpraafiswhkpnsprcxzsgolzqpbftapnxktoqbmcgcdaiigycynuwdwrmfdnmbdfrujptsejnyfxzldjlrabeauteiwjplajccyphfeovlhegtqrvyafwarpdurohblstradohhcunbatoxmrogoeyyoxqrcbvothvdkefglfrqebgqniruhdinynpzlkrsfcyqdtgrxjbqwnitjelgn", "kicxxnlcrxrxubjhkvfurdshrehjnaglvqmepofabidvtyqfjfwouhduixwfrulijdazqwarjfjfsrrnfyeueyerxrakplbprbnolidbhyhwumkepkdbdpdekbdlhpwrqibphjuhtcdofpapbunazmppccqjujccpejwxgkbfakghzzerxofvwgpayhhsxuvfiyhlvyowvbxrddoldzuzhlhfhvyoznelbphhbeljtffgtnnhlekokawrbijbgmwfutbjeoefdjbpydpqpsronwqpcitdkicgkuuzatmqxtedkbliogegsfwprlloplfllkcgecdrhbedabyjkirhyygfkikhddgokwhpucsxayhihlujxynwvuipbgtfqrmqgruegybjgumlpkgfbbriglhennygpjxrofspfeja"], "expected": 0}, {"input": ["gmeqyoxouvrlaeucnuiugaoatmiqxezrwgbylodxwnnektlohuevhvgkpsqxywbuesalvplhhzhrgghpoqlqmcmzzjekenomggiuqupqechzturlgfzcegmyapnoguirlnwnwgwggpugsigilbxslgztrtjkbkifuhsgcarvickjkipllmqbxmxalmcaldcbwhbvubhzmscarvwekvjymkaqtajnivsepcmvvycpvnbctiebproheactaiwitmhdbvbtcdtvadednisvvjqplrmlefriljtlwamlsvnlvtueownjiebklspzqokpmvrruvplocrrxcfcmuguubfngxpqxletajhqjjuvblblkckzkeynbaqrmjutvhfrzddtduhwhffctkqfbzbuibgbdaravgnettsvyqzstcyvzfhtmphujvsanusbcliazxgfjquaksewkyxqmnfxypqbgivcotrqkrbwlguzjwbcxkepaqdsgyavrrmvzaonommpjjwqetwhemumpwfcmzbuzldlvftgcmojhiyasenkvysrlgtxhsxptadajurozguixgmwjpdaflnpjhoqbrcjjnhejmbuhiagghensvsnfrfaexolmnafimnaetjyeomjjugeknkwxaeyneviloyavitpnqnttxsmuvoqfidymkwtdkwapxgjlkjdhnagilzbnkbfoeanwzjkcazyfncozrdyjksjsvripjvledaddkyrdzflgfnxeinskmnudybwhtbkchchvxlmwyvlqovqmofkeeazvexdhtaohocthnyemivgcjljuogscsnqlycvcsyqfzxpmxzqag", "ekjreqpbbmamgenqgghinxgrlwdjcaaimstxevwuphnpjxnlrgzwulndannhmrnrcvywanimcustqtkspyerxngvisenehobnsvigajqdlhxpbccjxzha"], "expected": 0}, {"input": ["mlziqrcclzhpjfsjokwvibyvrokuwnnkfyoigxgtipiajzxrrsurchtcywkozcrgfmfljwqyypjorutlsxlltrrcczvmyntrryqioordfqrlixnfwotoupoozmhqxfakyunnwmajahhhdgsufgfegxmijzqnckkjrwmybhgtpvqfxfoqsxthtfhxwkdkmswmkvyisdzvxtxzwhotpdwndkfynowydspvifshzzjwrrraktvwierqowqpteocqwmqwvzlakmwettqhaudevlhoxppsgvcjtfkrtvtymmhgzingqnfgytikppmeofdpokragqmrxbqtmrhzlfzbxisvsgmouksonenopnwqsyptmbkszchagumiibgraqhmmdlqpmhcusgbkgvrgewobvildomdnvjmlletodvhtwyigrrfffwmxpzdgierjtaixtlrqvnlqxrqfxyphpfubruekrlnxuznwhbucesrnbribcgouohvzjsixvjjjenuffycatyljcqmdiyigihuioeigbqqrdwxpsrhcvaxuzkzvefjmabghkzftjrnmfnacispqgsoyegzkijgeufopaacugdnjwtqkcgkufglycvlsthssyilxeyqnubyiavnccosaetdiujqcgsqphbcpzsdcaekelzbabkpssebhazfsbboijqkyartfzbpkwxcnlqztytvocblfjsenapzxoucnvguwdllpnrrzedrowqruzomypewffkoxrvxgvbfdxmojgfopoimssgrxsehrijhksvuzdamcorijkkfecwdqrdmglvsjfbxallptupjymwoimcabcyzglsdbmfmyfbalbifattiabayitztqujcdrzyalfdispoooexaqfaeqlpvohctttkvddnxwlrlpbttqgkzoywqjjmvavfzoktn", "xxnhzogpqrspsgzygbibfqmwbvmlgxklcztkotlovcgqozrqhtslzhxcmwoahmhczpmjtkvyhnrnaiqfosgknhmizofijzrvhzpwvaczsuyhooqagtahhhlufpiewauyrpszxwjzdohlvapjtjhekhctfgswposkqgjjpoidymrtdkyzvvsdtzutosgnibvjxxnxojv"], "expected": 0}, {"input": ["jhjphowexrgofehrtomzpaicrufdeojrbtgjokhiltakchosegurtccquqqpeguapbnhynhebqivxqgmawlqekiuleldfyhgphwbmnbpkhjetrqfdnukdgncvsqkqfwynrjyphcqdecxceczbyikiqrxhprnxzxlmxqvyearstabmmbqakktccaoatterbtndkaznctfwokifmwxmlngqktmgixuwemuasxonpdkozwviwosgecxpnbeydbuuultrofjevxuobjfksewtszhcdltznafggcdrwgawtlxxjgcftgdlmudyppevltpxlrwpvyjlvlvymbxqorubajpjkphfevlbpqtdbfirvvujqgdniczgxeeiycjqfbivmzcvjkmjzddrgwxnxqkemqoodibkcaxbmwqkfxnnblunzclytimybaytzyfocljhphmtzfcykzvyrxsgssptjtuoeeaujlcmwbmphrnvsorprttmddhmwlkremamjglnjienrmknjbuncjybwdyocvuyiwnufhywefzaxcbigiemmsemvyroshooltuebvlbrbzwsboztgyliovwquielccguroptzvuxziobylybbqnsxvetjkfoizbptbymwgbnmulrhhytrdedudqaklnthkujlrfxzezmwxrwpprekqzsngbxmzjzbosiwhfbcyvcti", "bvvwducpcrioslzeototjyedlaqcjpmslmaxokehroxmtmtjtxtylrlyxgcatavbocsazozqotujuecygdxputuexkactfcygghfceyooqwumomqjjdxacbbpykwtcmzwmgqfynbqxcmrmtbqbjzywyeeshvvbeovrihipgbkbvnqnieytqzmbhrxixfsejhikpkurcsbtk"], "expected": 0}, {"input": ["phvfwigroubslojpsvoqefvworlckzjnxgvvszuqmiozotvqkzjvfuerlqupdwwfxnkehlhpomkinclmqvhszccfswzrdbfolohyytppoauaxjisofvxywaivcucwxkkpazkoznomdfwmeznngxesgedqlyfmbgicyrhcklksugghjsskrtvfcprmmeiqcuvowfjthtpwcdsjvtbizvlugfrwrszfudqnhpyxnenhytrkaxvnjpqnvszqabwsrfxlqdifauaaijtjmmssljlxsivsojmkmmlkrnziprhpamgmigamdnzrkgwggtkbwyudajojbutwwekqhbeuoqlnbomfsqagcsbvtjxeunbqbcdpuiuirswfwsamwbjxmugnlabsqjulncsegymkguxiyxiccsqhyrmtuviriomiscomzvwtrphsgliekqgkbwkmputvmuiggkepzhqbwftmhlhigzeszqaoqocvaibkobqxpbsxzkvyvbhjryqfymfnxvimweikuihkdcuytmclmplpyobwercscllesvnudeakgjwrpoipxywrvfgkeykibgogmiyscqidrymccilhaadirbqjzhbovhsgloldmvkvxhqhzkiwwkqsknsvhxempafawvhpyguzxbhfvldbksfbaoclivpkufrtfkkilxwfulidaclozhyndjqcpblbleermrlunihtylslibvolejj", "irrwlqwpyygntobuurpawbcdkuilnnyfykdykgurfbqnunhhhxwsbbtlwpaylmogmrvdcyakiymkihtnlwbobufaeygcjvaqajkfkqjdufpcfjsvkggrfctwzxjpoclgfvoeuzpeueajbxhfbizqldttumwruedrovvyuflfcfmvaivrjlqetshcbknpavvwifosribzrqmllabsqopmplyqynhugaputxaiqxqkuowngxnlvconibuasvakmzfpurqincypxnrcgywhrgkktppfoavfmorvfilrgqnkchakqfowdzgaivgohajcksibjkpmhvmscswmsfbjnvptsqnpbwhsphrefjqwldvmpmfmwkbkmicccfzwiepmpmaeofkolfovaiuwsmhyhxoyukrlpwrpmpquolawyexuuisquifkikvlwlmylfieitybbluhuicgsrclpbxyiaqxmjkbvvepkexmvimpfpmiegkqjmpssuwrrvcunibpyfxgqppucbqxbxqlzfikyeqhsxjbqlzipsliqtolhgheavsvlqmuvljzjycpdarhzloxyscwgsdphvmiolskku"], "expected": 0}, {"input": ["ukerxpefmdidnzqbtggftufahkkticehtqkuuokrydapjdfxhgmmkcewlddmzjcwoqgyvmgylocnxxexmagfsdmxrgqwbitryrbbgaajdvsddcvlayygqdsdkgsprlzrlesnlriangzpsajcaygkvcjvbmbkbypwblxioudqirvaopwpizptavrjtelzzxvnukgzbznskhcvbsuklhxibimphohrzqolqwikqbtfsmvozgyvklbgbeagjzaepsucbtkdtkobehjrvddklqlvuvaoudabnqmkjgdwysdelogzhcqsyfmciwtoijhdgtbzfltiftvgujciwxvvcxqgpsmnadrmvuefhfnxyyfqtxsnwvzrpqsugpthfpjzfrgrpkyhbafqztwoqdxepfrecyldtwnoroqtnapsmbvqlixmeyzrccmkbrlwpzbtwddhcxajnohmcpiusgrigdyryxzqqaewaxxlzdnymbeoxcqxjuvjnychdxkjrjnkslqlypfhvxajtfreaqebhnuupyipjgcyvvgduncalenzrqihihvmwmqkecupzgdprzqnydruwacsxoijjbggzzzaczejgnlcefvxveiiiphzgdayllpfjxnnuglazvkrkc", "txxtdenrqevdeafbfcnfdvfqultcqzvreroganmazgtbfdbbnarckzcsvlvnbfnpeirrozbfhnbthdadgerxvhveebsfnysxgpfqmqnmaxodgljdspzywuqwszxhfincncgyffmx"], "expected": 0}, {"input": ["zkfersvmdfdupmnimlsrammkuubkhjutctmahsntulbyxvxwehnizfgdsbbpwfryefxxntoejypnjmyzhqdityggbhddzuohbtgjhveqcveqfdtxxveodjmgtedsdiwohkdwpechpmbzypwbnjjmbgrnwaxaqwdpdtauadamlxvltdkgqvxxghibbotksjnwzrlibclkbaohoojgcfmwwyxxtckzltsokhqfqroqmgxapgxksbdvanqszkgzlpwxvbgnoxffcgwnpwbkprhiveslbowcybogyqnhqpubcjzorukkmjjeyakikyfcgqliukxiaupbuofbripwoffssusqxtafdfnqqgctsfkxyzhpqwqdoeeylacyurqgurnlprrlbvtgejpisryykibndppwwuhyazohhkuadicjqymfdqdhesqykekkqtmchlbikexihizrqwrlydiuuzjxvesljkqubeofvpezfkwnlvvbmrprfmznlcfezpkeslwzjsrvxfmkxdcnqkqndjqbaxdkubdlkzcakkvvklssvfwqxlhupjohmccmjznfkqxbrynunpaahzcxxumpgstdqguxevnmgkyvhmflwgqyyfxskyrrufrqhtdbnvxmoldyfdycjzvhlwftxmstmuhudtmeuovzxxjcwtmbamhhnemzzjjaifvsfmhcxqvnqtvwjubsakaannfdfsmhmbsrnzmfhxlocyifhsywiccwnudgmhkzznwvrbloucubekujiqthcgcfkhyahigisoqhzgwutxdyqynlfjklfztaxlsyhfangswkhgizkmfuslnzfcvvsyzzonmdhatgefiogrnpnnwtpxkkzttzoracyofrvglj", "bhurdyfmfrlcjqzctzhfbaxtrasokxhswbsjiopnyufcurriserzxkxaeuoalbhghdookwgciptgysppclfvpxbcondbqnrosdubnpewcoffxzhoqibpoqzqjvbudyjpgvghbrvbbaoigfliybulesvmbnjqqdoobmjdjakzkswafzjnhnirredanmzkyvbndabhlezpksrupkwkukrpdjlwqhsnfrjhlgsnnkadmmuxlxwxptycmhxqgzuxbbkktsuttlaasotmvgxdwxwgfdybkoyqrxhjhucjlsgofcgayjjopfxltdkdmwvsuzgjgubnkvpywtezpdrxncqaymdftmnidzqqhzqhemthgszcvhywcbbfpjwfkhzagmegpyzpwgjecmtbdjknjirwewbdfaohvivnfyhcbvmjqekkihzrbbhbwbcscdchgxkoqufsutpuerhvwwcghknhocjafzexfyoflvnmspdykxpishniwsulfzgksfspvoojgpogwepjiztfgykvadafjhqmyfxurndoqhokajfukpgnhqfkxrtyzfhkxrulmhmsjfxudpkdytprvsxjfmgfweawtdxnzimzzrbckzlwxlnponuubfvxeyhtpjrdjodfnnnckliuihitiozarhxqavgfwbzbkkzjkdwumufizxtjhjdzfxpacpfbofcrumxbdlaypqekujxmbogjulqqsphaglgtculxasmirhyrmpdgjnpqxjsae"], "expected": 0}, {"input": ["rrgwfcflvhwjzvwcawmmtvhszmseiaykbeyfkggldaarsvmjgwnfioflmgpimrkinugiemmmdnuljybqkeuzleqdwitmpftiasotwitpwwkphoqckqlsfhqhrfdjshfudidfqiyovhasxguswgyapplwswegltwtnzihxfhpfatlngvgmeaxxkryqtiexqrrbhinkhmuzlptanlwlabtrmujhzhnilueavlmvftmcpebllpbrmcdrhataehsgddxkvfmxwjmdamqoxwcsijtdfqbfzyusyxsmeqgqzdvfrhngnidmzrukajcceitrndoefuirxpevhtkyghxlxirkdgoctcxjkadcxvzongwbewkpfcdjdakyelticsvgfcviyzhqcwjmnquxvjakvyggdfllunpgcoumywujslofmdrvagiqqkobwwounmmzyivgyezzqedimnjtitgpjezrafzmlqinulcvntkbejxuhtgnyfqertlulnqntxyverkeoujhigtcrmycunatkafgovbqfeeyvxdkllzastysnfacfgoixloehzmtcxxjvzuohfeqrxliawlnattzjyloinbowwnbvtmjpwdxkghjgzegwhfyhxpbrfvlwfbuxueomkhfxsrnwossdyzffmcuqllvqmdcghvqyfmscgdhiomootutessfrzlhugcjykoqvuczdxypmlpeqisasuudwcipeyhhbxbtmtumwlqfjnselebztfodsgxivjvicmxupqibapoblripxvulylpnkxryypoqjhlbghljwwninipyzbhiabczymcgmtj", "qiylltfcyiuxkqrtprsentcsmxhbtaqaxmtioubgehgvvmpueiniuwkuajgdimciypvqhjxznuyzvjbnwrzghhbxbtqnujqckfthhlwntksiicvhhvkjceqscxbcusndxmxmurripllqdyjilavjexhlrpwwnpxlrozowehrramritcdnuezmppztliiqkprzkxwmimefjttbmmvemrvszhnuwwfemxsqbcniltvllhgiqxqkgqlelmgmfwyrcirnjrplggmggipnfmeszuqfjlczqrhxqfpqhwmwxhsptelplhjilhlpfhwetuekujeow"], "expected": 0}, {"input": ["kbemxgrxdviwdvkjicrdcdujdllppixwvepwscpgaucqbysvofbtqqltlemzdmjnyswtrohnsrqnookwfpvolpbuzyzjrzubbpxejczrsquektqlaxnmgwkzwkdjprjbwykdbeimxthuxaavtzzmbsnlkxbrersupvptohgjoovckpkzmlhcpjeqbiewjwqujjlqoirfvvmsxjmklfqhlmyhayvmfzfhhzffzgqdjazzudajwgrrydxkogforyewywkckrvzurgfbsgqazbpvputtxfeirfkdzwejernfghyeuntdleindvlhntlilhfjcmawpablkyzkfxypmgsibdbenvlfijecfsavvawbptxemzxgjpsygmevnqackhfxdbgjsmvinatfrooywjrtxiyyavrqxhjnlsqsrnjzksmllyeqszlyexhtkjkj", "bpcnvcxsfhoczcaxwrexzwbipwmfamrwzautpivvrfgzxgeajunjuybrfricypstajtkxewjspjzevcvjywekfzkrnnldtehdlwhojbwyrvgwagtovvbqdvxlwypqbrvnjvqkjfdverdyssmqupuqrxhhppjpvzrdllblfqkbymdqxfoevxjechghccqhhkinxwxrtgrameveyqaakknudulrpkkjtonhpfrjjrtgrmsrvwygtxgxjsumshbqxwtevorrliktjskourmvwxrbjhhvkoemybwzhemukncabtgtbhbnfsiqvktarxagjryr"], "expected": 0}, {"input": ["crcnpkvzoadqsqsxnnmzrnxztuqdprchjwrqjljyewdgrfqlivhfeepieuscotckdsiqwullmfjahowojvztlsmbvsxrqpdrgwkwoauknnyzgjqbrkdetghclhmwggevxpnnhfrzrjxkjlngpvlgmexpxrfpljwbrwballpsitqptbkpyzfkngowqrctpjdkqaovvcjdwcxcitivrejevlcooclgzoujnibbdxycbwtathxddqpqsjcwolrmxhxpmreweicxbwpnvngxveeivexgifswgssomvhpcmorddrvxuvplczlyavyuuuepsbogkftuqmgiwhuxrkojmsrodqnpxofmspfqtrkeoybnyqbbmnhsqtfeckwbztlyjlajopslxvcfjqmclamzitvnedapioktvatosbzzewmeeskarywcadggyjunysktlkvdkpzhglggfsnkeqqisqorpbuoxyvygxxnixlgbwqgypqosbxsvggonkxbtsqiepbhkilrpentpyxctxqbpaylqvogxkfcqsrkszgqtpgkbdrsbuwoztvkwipypqzkpfsakgcoixvylfwqwkbyalyzmdrnvxpgffdlzinollxrokpgmnvwfoicwwqmep", "akxtvqbpkunfsfgwxlztiqocxojkufryixoqtfiepquhoxldfpprazozaelexrjbgoxnxfzgodsjndvnakpiltwudcxbmkpcknhkjnwrozpdzbwytrxmyfqywcnzykvxmspwcewgwnpmsopqnqtsuxumfecwkvqoosconqqwxsquyxomzlnlhjomsmtozobozexhsxrpylwtqxiecwnivtitvzevfvjboxvbcncfrrrpvwnqettohmxrwinoltfcctrfsgxcxpziwkoxecriukossvrvvwxmniesdppggxonyzxvgpstbbngqpcdqclnlhppnrbmvmzxxxwlsaamthwogkvbrqgvsqjpcgfaaoakrofykiafsifkiqgxdgkrzyvixyyclwvexeobrgkmmvdbxejllizpupoabeemvx"], "expected": 0}, {"input": ["bfmwzikgzkkcfjxorjxldjxdspusguwyoyfummlvzptxbnfrtmtlbxhhgbpgbhelhuecwsggeuuojrotxakgbpeicwyetacwehlyfsblzpbzrjkaujquftifgqhogxkqjeeiwdixjqtvveotibbtfzbogwvzgldutzmuiebxyowyafmfzcxteihwtfwewlfoqvhcxmclsldhfsqxsqpmgthhfusxwakdrmflawnmayuaizhkjjxoqjindtyuvyxszaktxjelqvmejcsoyopxtuqhaxwpfpyqsggvoawwduejfrevifpukmhdifjzajayafzpfkenpknwwgxqzpxwzqqlybhgqthodtzpzyzehmiyjbamatxbmmrvqrbylaaqiywfypxhezggehqcfnntglglssbhqyswicuafkspbawdxxnfqofncyhdtviwnuizhbzlwknozbrvrqiuuuigngwqmmctktgjnognrehvbltgvgmghcsdfkvutqmovjzjdyvlbkkfvrewdgbxeenjvdibzkwlzqlwtmqeqmjlmmvjgbtassmxpdvgtyuufjgullzstqkxlpoeltgxpdcocsouzwhlqxxyiyzxvtipwkzlvxpxwrdesdukghxwffcladgwcjibglixttajferavqziqtndbyaduzsxspghephejdijzuqznvooduooxolntsxvjjzjuiitbdvwtghckuwezdzaeztmjcjpkbidsdcjlqkeefrgmyiakzlzahmazbktosuzinocwtoijtuxozcztyzqvatcnqbgbesrjkpbgmvuvsfkpsanmnuaauilmujdfmjquxwhesvpgqcwhimadpkznysobfpjycxgnijvyzuhisjnzvtqorswh", "qnoilxlcwcynqpxfhgswmgvtdhdamoohtktaocvdgtqwfdzexzffbueacubnlwhywzbbjgkwblkssiwejjtrzhliievuuzgtjdfvmiwfsfpohtuarhgmjvxutckwvsxtjytuoctkfevlihqztftaoejhxymqmqjqslmdvgftdtscwqoygrhgkauagbmfnxfmynxetoa"], "expected": 0}, {"input": ["hfeczpaiqsiwuozceyjxaosplvhudnrfemplynaveqqgvlpkmtyfgjvlqkigaijrxrgbrfgjkmmuscdtzzjuswwanqzbmckgrxdzmjhtpgegfffusaqqlsrhbqphbazmkxwvefjjmypruufzouxwlsbppbnbhigdnchhtksajjghptqcpkvpyisuyzjjboeckbvmjfilkbesevgsupczbzbsnxttyswfzyyzyquuhwudiaqejwptezjwrlghbypijjvnxqhudjvighblmrwyadafdpwybohvlagzqicrmaoqisovmohmvcjxszzdmdzrlhrdkgwgooeqjhrwymztmagdowtlyfxuibkpjvhiklvvxlilpmgxfsgbyijfequmsmznouqnunfjphjnwlgeeldijvebhnrpjvnsuwtkmdbxsluntuwhsiiiwfxmfhmooopiarrawtvricditgqjsuchxfgofitbtaollxrimbmzesqtivepuwemmcixzaheqlfulansdjpjlbpbqhosukqzaw", "gqqrjxaqtvjdbsuvaorloqsgirytvyyxhqdzhgeoupbpvjxhtdsuecjbugrjzlzibkrkzqoihadvluijwiipmqvuvuycylfmwukqoqedjpxmkwebxegbbvaimjjjgzzvcmtvxetjvgvequtapukbilwzeejsmuhozksmujmqrquslmnkegsjyuiucmbyzbmmeeeurlbiyrpypswbhziqghulqupqqjcrjyfbvcrhqarnamwwzsywhwnkjmblphwdimkoemqfdfgffjeihbpbojimanthteisobobuqorylnfomqineilmmqarkgmbrbhhvusgihaitpiwgmdmejmibscxczcmxkgcoyzdhxpqnshxeksqcajluthwmjwvyizgojjpsxmpidlelqisjzadedskldhppteglgklqfzialsheacjfchvuimrehmaqdhttsslpafiwggzajmuurzvjjzbgejgxwdbicwlpzggkurvbegmhybzelqwbpzcmspudgkzaiwbpl"], "expected": 0}, {"input": ["lmolutqrqnoqojlzzpdtrnfgivavvbhhpmhvzhegoxneaudgceqnxcialryvkknstoqrsahbqwssgnhdqkhjmheqoryqskxkvieiavuzjugqhnxeahndpnjofgxdsdnxegpckilmwpomuithonfslbcqqhjlospvoxunjmnxxhuehzrhhpohdpciqitgvetwvrdknhbuxqfcnfmfawpscxelksjfhpsjfxqsxxlrxuzsbnjhuktbjtvfthcazjxhljodafcxfeailtikyryrnkczaqpgrqaikdnezkmbnznkzkwydsvtteufjlctytopjupcphibrurzrjhgwakwspkrelzisbonouxkljavltidojyecqdbaoprvttztquqqqvnslnucmcvfmylaiscidoqannogqsibnzelikmzqiblezjjhqoiwlwuauoqgrnpzcndgfdtoodnvnhseunflbexhwgwtavrukfxubwfiavbrzvsmcrulhngghrvuqnarbnwgapznwdmpmckzlxjnwvmsbcswunll", "rzwrcelndcgdhjtuncveahfsazhdkvkxmnoqtognzrvihtfniuweicsdunwmxdireqptvyohbvocbtnlauxvlhdxsmrvqgnlalkkaiuivjlsqlrxfcwqjrxegykeixrhyxziwhxlvvnungltdygnjfdkumikkrqxaibpbxkhmaigmiaegslhnhxtdsivjuyqkkdsrsnppwiwnjssisrixlajgucvlvieyocutohacrcozuppaoqnfjrgxqvfwfleujfzehpkfclsvcjolxzijcsunccthpzfsjxjqitnguafkzrmjpvliznnjqcglmniswjacuvbswnknlpxtxkqfvwmiqfzvxsosivjoxlootegkdsaybqxvndtrlhejnnqgvzmuifnliaruqwzet"], "expected": 0}, {"input": ["crszbcvkkekdknanvbrlsygghwammnwzkpybxnhsbawskeksospjzupujfosbgqxcnzsjhuzecvfjnqjhftavztnxenvtsznojujrrrgzrimfhwkxfdgeyeatvoowefngylddwsgwndhxjnpltwwesafxzisbpdpqyktirprppklvizzuvmhakrchybybxweipafmrzvoyaibzlttyceyllozeowrhhhsuoqfsdjugzyzlzffczldldtlawazqpciotcmgezsakmrihqiriftvkhccwuuvuhbiqtbqlikybpgmweqhyydpkkpewqvygxzwqfiingwjccbolpigpxpxyrttjfqjamwhoqmtmhbbiusabxsmbaxfumktqzqbxvqkqihpggiqqjylypomebfkjhoybgcsqryzjtfvysfazbwrdauhivrrimfryvisopuprqennbykvqfirmjrryqpngwznttmhhofihveftacdsbmxiosgpqansxctadhqqfdyzgmmxscjlurojkowujkwyhyciudbdodvdvayghejfdpqtuttkrvnqrxquzaqpoyozbdkloevriefxzpdokuustcesimhmrlyaaofooalfsjtrwiumlqwofvkbcecoummjhwzqdwhbrskacvhwodxebjnikhewsayjifqbxpjhfhapmczcpzfvuwzzendkwftuesaxhtuwngywxkopprhnntoadpdwsifddpuejfonzsolddaszxqgybmbpgdzptdnigekhgdpeodlvduzckailtxiybyctimgujzsljpjsrdnobjclcmwhgfisoejkazrxcmunjpakuyjqfaubvuvgnacfflseppzjnvkexkojsacedohjbovpsernqxaclxiwskaglkbzebpejxvosahsmuqmlofvqewhdotizgmoafguddtxfidozvtpfkohrczlqypcchlfhlb", "qhpevktajcgbsbusjffnlogjgwkacjtbvxqrmaomdvvoxovrxlmvapotqzoajnyphlnrvhgazfhztpdftsgqfdhjyyxaoqhwnzuqjhwqsqjijrborltxworihwokzrdoorikxlrzdisbneuanxtndlooacdouwbwjehuoefpsvhysfoccppxchqhoymsehzjeoszusqjodkninfwanhyaqtzzbhftolbvebqqghzlvvuygwzhschxekwfjppthtcypayapuipaqssoarkboqwuloabfvrreeanyviglllswpunvyrcljkcqpsvuuazckuaygxyoazhutfrwmihvhgtdopgoidtinffzssyhdqqorfnfaohltkgwcllhuppuwuilvbjefhehrwayjkkmoohonzjepxafznmbeviyysdoueunoohquqbopylefixnjmxublgaabsswuzkbkokwdtevvbmdevsumrlibpjksfrcdcrmejvmosgjqcupxbvmutdvsokxfmiyqeaqukwxidpyeusorepuftdxqsfkjiwcxsjeosdswuxhhezwompwhtmgppfhzcnrmpnerqqybekhkqjmspsuaykekeufigaropjstucyapcxxlkkxcnmpdblbblzcqhbsilymoarjzcfgqtjtqzfvgkaxnzqqbwhjymkdlzhebdnfxqluigdykmnfocmufybejiiabnhqhpjuuobohniycniiuqhzqkzqndwzbmpiygeadrrbcedznxlokcykickzatfrdpkakuokezvjdbmvbbooomtzihftdwrqovtvzrszhjvortorewttpawyjzfdbleqwgkdxnreceofpdk"], "expected": 0}, {"input": ["uxyjrhpweupmodhpwlgrhtlacslixxgptgvoknubpmkqdvvorkfunngcjrmtbnztkmawthlfjbaezafajysixyvwygrfwgzruhsfhgqtbdmknogmnvecbdhqdduckochiatarvkfqjdrclsqhgbhixwhaztykndohdqrjryqdqfjmgpcufdtyedffkcdondbfkmwjzekpqihnnchvddmevcppykfhanetnguhkrfttsspkrhpgetjiyxinsnjxvwmdpaspuufskfhgdsajhglrwzopgmsocvsbyqmpyrqtueeexvrpnkqdddukexwbxavfykdqgtzzjclzazcmifbcosqkfgywarrneskbehyvkcpnenzrzjsffjqslitfncitszynvwfceyivdxmmpsqaecmrndehovmekuwnvqnlvmjqbieyfedphbbatvzawwjmlernxdylvqpwpcwepghtnacpclcnbkdywoaoiluqdptratsunhngspikxbynehvokcgzmyeifursubzhutiqmlucrhrytsyzslgqjotyotwdvwhxbxeqxmxiyajsfxdzpvbfghwpoxjvecnpavjaikzwrdvsniffjuoummxjdcwaomlajj", "drqvpvtwyiaciebeexrqdvgrgvdjcbqprippruwqjpvfhcpxhivufitfjhdpodhvaigpzyugdreueheulwspivkevtyqvqsovectjeja"], "expected": 0}, {"input": ["gkskqybfvukthextlgkrspassifvvwtqfaylihbhajxadiihkpbaxbqjvyudunsfswlilkafrlkxpimvzkdmpqxzdchnptqsqtbdpxvlbcwzbhgusydzbiiilxavzseoqyezvpbjsqydvpsshctrarwekanhjjxmdltqvwsnpmhdiaprvuwkeubzgvfoclpsgzsnqdvhzafwpszooqgnarxmwarbzmaqaedhlhfoaypdpdhtjeoerajiflwjizjxeqevhrxdxpxceuuycbgdozwtzameaemwkhysvdzswyvcfuiboptgpgxgpeaqhtydslbmhpngbhkxgetcngrezbdbfinrmlimvwitbduwyevanxlgabnepenxzyoqrwitslavdejpsslkkxnlmzqjrphkerqrcuptbcmouaaiwglqbzeabjykxrswpnblhxbqlxhwdjcwvbtdonkymjyhdsglzmpqvdfevymrkcumysunnamrfmzfelftsdboqohvipfgrhfjhnlxaaagmwjzcofkoyjtykyrheqkgvutgywnzusysmetpdbetrkxfesginqvuuqqrqyesaguqfugiksxiv", "paajieexbkiifejcuflnvspsnqqehlidajywarzbhctpfznfcdtdmpwvqbgkheekxlfiydrvxiaytplsycwyxyxquktlyvuxggdyxmhabzkfvajuotuaeaacpcsmjvsehygkqmogkbhecvdmcvmsknvmladxdwmdvaheepwveawjkshbbcbmedmktpoaxgyjzlkshkkhceprorahdtrhgqllkfsioubybubvtsheeksaewfpdqjzewdgdnmiwthhufeeystnqupqisujrqkdsbvjceekmxtraqtgmdybqqmmarhiivhkniaqswilyktmhfxhdkfdvlufxfhzaapwliaswfyyezxvgxrw"], "expected": 0}, {"input": ["dliqhdlnptxedwqlqkihvyychqezngsmcetlcwfsiqqyexzifevocxikwrbdquwkjdxwhooxrxbdqagupqwlehzlvjlpaxvdiwsgbnzljiktbmasiqrqcljikdytpwjgqhjmcjuoebabthgjkwniscjimwsmmatjmnmsstrmlzmtaqclioffvqtrxkrinqemvxsdcateafoxvnqiaoednpypobnnvgbaektsncckvzkooangpuegmgqjeshygzdevksrtdgpwdsvnqertztmmdloxqbmgnvyvofchdgzzrtckjcmkedbsnmgwyepkmklvcnnqljqgepmumfkizitdafgppjcthkfkjjafyjuspqdxpczcmuzmqjjqzrcsxwhushhjmvbqcseclfnumynypoxbpzzvvqofrktefcntgehhnugiglepkgjqgzgvgaaedrlkmvyxlapkeannyobvcolmylpwnpxevsqfbodrofprmvtkfgcucgupjquajkrparmqdaxejlulqxdzupuqibqaiptnlwwxzlplzckrnuyqjzizqghdohjrkrucgblyxawevlsadeoszgcnvbpyfjroqpukbbzdugnulclhffhnsrkxwvmagzsmuqcciugaitouttb", "kyjeaevqpikqxopqyiosebm"], "expected": 7529459616}, {"input": ["dymtjbkyzabieorgxosaiesefuahcviwmajbdxsdesphcvpofdlfgtjsnkdcxqvilaojopzigxsgibndywbudztxbnqybijadkfqdeztezvurrplfzgcaltiwtohbtqaszgxdrariaexegmxzoxdagufcbuxjnwjxewdbpsdqlmladqomfdpayeiatbqzbmdqtdbqnoaevcjepvhgiisqafjtyxjkwskhxbqshftiyoncpdsbrrwbrthpuquwligrqmnbcymiftahvafmdvspsszmqiyplxxxzaulgugecjvsemkjdtwqakxvgfcgclrjmtoxnzwfgstagzgfveimycxgfjonvngvqchfhuhhlhxxttwymcmsepooqmariwnrvzwhitrvrviwwyspnpjlanrlacychorrnrwckapjxicudxcyfzzvpzybzafmsbrewipzrvremkvbmnzwrdvijqjycxkwajqxqquurndlpbuhupblxbgzchniabgvyldpxrlfkswskkfsyjmfqaxxqunnbzfdstywpzpwyfppcxwbupadjvitghmjjycoiausquwmtzxbrqprlmqzvfrzmrwzavpljpdgqiljjxhrncmqiohlcksjrbogktifzgyzovpcqw", "xgvhiayigmompyquqbvaccdwxpnagxjxelddxmfzfouqqtagzjonuxxmzyvaczyrpdwvpdgrbfnbqbpfzttlvmrzaislswpkwcirwljgjhcudtntgwahkanlycuklqalqgncdftwspinxrscppdbbpdbfkqcsbshiainctjvcapgzjdpcjojdqdiiknzqomydaqieiqzctvzfdzjscivaxbpyzwyxvbzqzrbsg"], "expected": 0}, {"input": ["ebgkuobenudholowlgyocwelaluiktzoeidhmotitovoemclimcwgvjcjtuoadibaduzpcmurzuonufpfjwijkmebxyhmvxzcfsgmwykqrwjvhbugetcpapmvwcrzehyvlvqgeimkiyethqhvmlbwvmtvgeroembqgqgzovjviwfkresjydcngquqwqyhpkchqkuddfygcxcabodtumaamqherlbvbgjudelzmsurdbpwecazivhxgdktkedjaxrziksflzkxbnqwvqsnatchlaohqutyeiazowykyrmlsmfyccxuusqorcdrngnaruqsztqpvdlfscblhyqrheiatburjlrumwrjslesnlxunfibxjwpiitijirqomobjwggidhkqckuimnpobvuaslnqseykcfujqxajagaorzybpbykvjleueohaexwnuytarjnvzbaanxyvadeuimddxjnmknvablwihkbqnvdginhrqtxaidsemgitnmgxyjmfkbrrmcjgaexgodappjnwsyqtcpxecc", "abztggrrfqngbpchaucdyodxuwvmiaoyvrbewwatomjfdtkcidevdbkujdjwgdgcnyklewethcwyerdelgyvfcrksgnvbtwgadikarioqzruluywanuepjhwpyurzekeeqxq"], "expected": 0}, {"input": ["nesqugzoeufctsxtmydbatziunxgzcwaqfnej", "iwtsiwdcqyyxzoxttcnnazeznzmnnfxxg"], "expected": 0}, {"input": ["owslbdshfehjqmojivfxljkqzfekqgvlidtjmejsxqppdzuxyoqrfqsmizqnwogrwtknxykiqmnvfsitqqipgedsvyeixhwolnhykunsnmcylzuotyvovxdnxmsuuhhziirhuancnofbaalyuqifuhzhrsflsrnvuvoorsvlzbifbkgsrojylmktriwylww", "yjbuoimijwtoldnlnfkqwremoydrvrfqnvevowgqnpsmbdalalpsdixppsicq"], "expected": 0}, {"input": ["xlixfqzlyvydmnmcnekoioucanriuhlwfbzyiekrgjlspuakizcwqmhmthxmcgwhlumcuysofpuwwwhgbjtelwlofkfzsmrcvefrrvlzqzkwfruavpigdmqhaniixfbcoulmrrphdeaegbzyqcebixrgpgqlqtbiuteqrwkswywzzufcnmvkercfetcwvgfuuwlvlipyyvndifxpxitubfeygujkbqijhaivcpjwdcugiwjewfnwlevvizengoxxmmppnxpypdludpjnsqddtplrpimkmtjfnriljtaciiljytvtcdsoqjktcpbaxucjangxkzbfwqwgoxcllnxsnltmjvcnkqecqvntkllrmprmokgmvkgrpaonvzjezcxitflprrfiaviugrnlqkupnvvnhgqdpbyrgcbjvmycqkbjcshykkfbkzfuxiilzzwxxnuwptvpnzhuvhrpbnnxtbt", "wnktjbmpiljaedtykbhnzmqwxzrmsrfrxelaaxugxxpxxkezlcphgkpapnkxtnqgolhbdhcmjtsbwvqvyxxmxzuwvepvhvl"], "expected": 0}, {"input": ["qsudeuolftlozbpmwvyqlpbtzdngwfevdiwrgzjaguzpeenbxwtffkdzqdxhlfbnrvoomhgwizweifxbewbjhhbxsepxmekfzqicyygosamwxuqhtazckhffpuhfnabuicojoscifwgxmyieciumopgsczpredvqklbsbestwjynrjqjwfccppjetxhphaesmwvthcnsjyuujegzrwiiiimaiyiihdzkehxzlopogzrhwmvcwgyqtcoksrrxkygnehsonziyoawovefntykvesxbshfrawcmpmpupavuinx", "htnfzymxkblbjkpomrhlawmfofyfszztpuhniofsbuskkhyebpwizilycziujdhprgihvw"], "expected": 0}, {"input": ["jonmsotyquiluqjxlmxazkaahonmxujpifjzzfanlgmujtskytvaqhejmlbzqxdnqoppaapddoxmwdbxincwtnqiyaeevanyvzixitdxnwtkwqemjpckyghrrjxmjoahyxckwgnrdytxnkfbsefjqbxncxdkebgwpjwkgoxszyhnztiycwgerzuekhtvzjkrhzparzygfmjjetwyhipznuqlbpkkteiajahyizyqffjowxxmdrrbsugjalcnpwvwtbntvwzhgmizzdwlpgcrbzrzllcroinhhcbnuqlacflbhlkptdmgkishawtsucxpexfuuqfplckcdtaqpwhlixohrqfyvigbqomvgbheihviuvqqpnlmasycqlklxqnmwrtchfaueyjhpppinhxsuqflrbsxcaeocrmgtkitgyiqvkhajicoudbchnvgzjpaqsjynudmznhsufatpkipdnpmuykvfndwmqqdgkfeqqxjeejxxebbftzljcwyitzckvntmnforotdhwpyiomshehyftvzbtsgaaiuspfazbtjbnwqxfvdpweezzwzigaiuolnpbfvdfjcbbgtyhkiuovltbsvfwnhpqlswcgzjiveiianhcamykdkyanlebouovwrwpwkmzhatnxghanpxiuylkqdexgqtkidbslaawlvxpjsnbcwccyugoanydplludahitsztvvmngzyervrrwdueordmofmguowblyvwkiynhedoeguxwmnsphhhpdkpkzyqfhkxvzziupmdwasvzyfbmwgyowbdjdzvhjosktuozfznwilzjgkqogyepvwtvxcagmnnjuidxoqxqcl", "idfnffedubqnmwwmhugvuetgncruevvxtqqfjnlzkrhbhtaletfnhzmjasqkkbkhnlpkkhefsbavjvgqawmlzyoxtbnkwajglyfkyqbkjlpjzyjuvcqoahqfhctgtewwpyopxyvkkwbudvgahqcwirzsaoxhkrxyhxypsmlhgwncadzqkvzdkqsgtgzmdhmeycjyrdeibdnkcwnzhxzaephgkhybifypjuyykizyyzijxncmvnwpwkxafkbkrizwwqdebzigtaejkkwgmkaclkznsowoiealxhigeyujzmygnqzdhdvouhkiwkqymwimsvbssmxieeiltezzoaryhmvhugntxzdaouushhmxvlqehryypqklwzevbaqplhudiqgyzzlandptpnuhxijvooahcwrawmqh"], "expected": 0}, {"input": ["vkjjxhfjawcomxbknfhhpegrxizkkasxxztazidgvbagtscrszqkskfgilactkldtbnmrbatwfeheqhmjxapvzspzhjekztogvjwfceqrywhcnwsdyfdkwmmjdrgcborqxlmvlcwynaqzkfipsdjvqpholiectivpwmeyihgnbisgrszelpgnxptuyeubwkbgvjkhgmjwyzhrqklgjtysytumnrygvnhpynlmjhqnnnesenntszgjezzuamkgcyfxslzjaktekcziczxklzyealyfsbsxvczbtzexltvkxghybmz", "vldfevsgncyaedmeeuapggxzpnjpkbgvnfgvswathxrledmegijavkmknhftkewbbyjtklkwqdbjgtcvkgvvphebqslakzbfsdcbpvczizlsorxexdbwqlxkhaloqwtfzzcwniemoyrfbddgaxyhmjyjlztghtvzrevclhvxrlbmyanhwklgsmcetpgozxtniihbsvweypkzhxjkgsnueglwmjzmpmkxgyxewflfnkyylankzvkiaryszpkzdtczonresibmpaonvhvzhzhchzefj"], "expected": 0}, {"input": ["bwqbjdjchhhwtswiyacrirjdmastrqrlbtesyrymxfioenomxnluhofbvpfktiohtfubmvbnyeyqonpryemzppngpudruwjuiypjdextvrpavbyjwxforovjorigbtdksujhbsqerpuscuquljnhekcvynufoidxndagnufmetanxnxgtrssbwkjdmeifxkfgscftfnsssfzeoomehehhjvxmjzzntviugpxbbpjpcthnbqimpjaguutscimoyhrksrmbclyugeleqphnrvtxrdfppcuetkgyzrpnqybxlknuzuibvoajujdtjziuezoyoarlyiutjkmlggqmtrmkypcklklanjypqssbejxwwovugdboaqjfrovkuelgdkayiaprgtidkbcvpvpkpxokyamcwhkxckqhdxervegdkmbdrkhytybildrfnhqwljomtjnhflsfadvmvblhdrdcjiysxxhmk", "okxfrtkfgwasofighyjfbhjmyrnkjovrmel"], "expected": 0}, {"input": ["upnksghdvzrhrfbmkipqebrbbxjbnsdioysdfxcsjrkylbwoyxcirkpewtuyvgamauswygwtspatrkqciloybwyvqeunxjcjrzzwaioaiaeeurgjfkwzuucqzxdomkvckkvkhkvtzuafcnizojmoxzqabvejveonuubqzrkatzxvlwjajlhacrmnqppclgxjyuyiwwccrloohuxnolwpnnkzouzulsnvnybupelygthkcooorxsljnfqtnfqwtxnnvjdvnaerwclsxnkykarmfqwsaiuddiaftpftbqibhxrethocalgtklfrtamdmvhtsgrusftkjigibtgsrtlzhjbuvtrscupdawxtfjxhetvhiuxfxvrqmllzumxftmbqrijugjjhbjfxahkdvhamdforquhwlljvnveczroyie", "crctluhebwtjgvzbuagpkyxofekzcdjptmenwextffoplxxstzedqvmsonwnwnoelopgtmzjzoudpqogvmixkjqfbkzldmmlxlaifpnqeqomgaykjyinsreprxyenulyuhhkebztbjtrwtltuiswirefbambizepnrkpectxvxxjwoldllbxrzxijobbsepvwfcxowmziguraybpbekvducxuxkpjraayqhetzqnufthofliapusqmtxarrrwxgvkobugtfcaasdayaoxolwklwulhoojoclwlwzymrxfpktxfrvgcbemdpjlqcmojgkwhkhhxfapxkhmtdjdzcxgnqvvtmxuqbnqiwarlfxdvhqjbmuhnawbsyieounkpvagtivfhofnvlzlxkvhrtgcxicxfn"], "expected": 0}, {"input": ["oqfroggcgtcvucikabgcsftnshjjuwilaogxydizhzovvicbixizhhncpuooaqdsnffonrptzdkltznpcogypicgmvmxfdndsoryarqqgxafbekxbvvqloajebopfkomjsjkgynexttwpzvvdxdgqcxoelhirvylhuvggzzfydnixexffemkwfshtmsjhcbinhbbzhclbsenoonxeuptxtfhamqsgibgdevhqfhcbjtnfnzzczweexlgbapzuktocztbmogtxxdhlxucqckyysthzjxujekqifwevnkbvwyitkwsuexatkkxbzqusoehcvueqsuoakrcscezurjl", "bkzuwdbxbjxzgenxqstfxvkohpcbogsxjhhxqnmbeoeiieox"], "expected": 0}, {"input": ["sbmjobkjxvfmagkfkfkueyivuaxduouszkcorpnfuufxigbkjwmqlaejftfdekbfavzwjvxumdjisbwpxdvaioqvbekzyuwndmiowvvakohwpzgeseqemddqpitchzhizzhtzkzuklpergyclefnasuvticiolvuquhxxgtpldfltzgtbbiarfdxuxhjkalbbokvmbwxumtvessjmdijtyfvftcqsydgpteqwsovmxkebxetqycjzboxpokofvmkhmwhheqqvludamfgylzpptuyiyceeyuyxeauhdehjhbngkzqappmjglxjynqadwuecmafvsoxlogbnjkfdplxltcjbjbalilaoncgaffeuwihxgrptscgqintkpjmjxhwgprlzenekfihdljsyjmnnwvawuafwhtctatbefzdlyzibeqfjsmfyzlxzmdbzsuydykvhurwbumhgqiylryxyaembndwqptefemluoadknbjdwzlwwlqexyvxhrwdggscckutggszwxbnypzsgyfktxuepfskopkdflhmduzcffqcnaxldmoxnuddkudwwxjoddyqwviedehibnqzktdkempvrrqanghflwgthcleeufuwhlysegayhgyxeboorszkjtsqnssnijgnzuambuauvuyebtetcpmtdwiqjuuyejoeuvwlwbtylosjrodkrcydwjjjpwucontttcrftnthbuvkzhepckhspsomsxyckbjfmvixbmtdihhevuwjzibgzrkohgbjkwrclzmmocxnqpqaqsezjxvdftntjiuccdjbjtcrfqyiwbfebnlfrjmuzaasihmvoxosvxpypzqzrblbybvhpvztbccntdessaiilbrtkiwedmgguqwfwahnkoswkkcrudqlysdzhmoplmtjabcurteplzrfhmwrxdbhmbdxsukquzvstohbarzsafniyxscfrubgbopoewedmzcswpyaxavdsesq", "trxfzvfmpzrojdgvnbxfjqcujahqdbtribzcatcuwoovldkjucttrmrilbngzrbpflmavlqvissfifiqdztggplhjqevnxdaukdwvwscvuyzkldwrptwemflomuacqjqlbkjmqprexjziamjitosgtajfxzmcbjrtexfxrgfohisbnmycseeteuzlyvpgebdkxvdcxayhifqpqhesxdbjymlwyrlbqjbofyiskjmbhvmhmhewavpldalrifiseaxfqzegsftduednybuiujybkbugayzvytttecatquedfesdfichybqbfdszdoegfogwtdsmagldebntlnaxwktedgttvhwfeiaueybjuurvhdfovnjemvgchyunxbbkegslwebhunebiwkjcrruyamresfbrjqdwzxhzeeruqfivmjymqznxjbihnwtmsqvubxclmsnfxbvsvkdvrytuzllmylkmmolerbcrn"], "expected": 0}]
|
first-missing-positive
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given an unsorted integer array <cod(...TRUNCATED) |
41
|
Hard
| ["Given an unsorted integer array nums, return the smallest missing positive integer.\n\nYou must im(...TRUNCATED) | [{"hash":5196614306897904948,"runtime":"511ms","solution":"class Solution:\n def firstMissingPosi(...TRUNCATED) | "class Solution(object):\n def firstMissingPositive(self, nums):\n \"\"\"\n :type n(...TRUNCATED) | "import random\nimport math\n\ndef generate_test_case():\n n = random.randint(1, 10**5)\n nums(...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
firstMissingPositive
| "[{\"input\": [[1, 2, 0]], \"expected\": 3}, {\"input\": [[3, 4, -1, 1]], \"expected\": 2}, {\"input(...TRUNCATED) |
permutation-sequence
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>The set <code>[1, 2, 3, ..., n](...TRUNCATED) |
60
|
Hard
| ["The set [1, 2, 3, ..., n] contains a total of n! unique permutations.\n\nBy listing and labeling (...TRUNCATED) | [{"hash":-2445517919244890175,"runtime":"4463ms","solution":"class Solution:\n def nextPermutatio(...TRUNCATED) | "class Solution(object):\n def getPermutation(self, n, k):\n \"\"\"\n :type n: int\(...TRUNCATED) | "import random\nimport math\n\ndef generate_test_case():\n n = random.randint(1,9)\n k = rando(...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
getPermutation
| "[{\"input\": [3, 3], \"expected\": \"213\"}, {\"input\": [4, 9], \"expected\": \"2314\"}, {\"input\(...TRUNCATED) |
two-sum-ii-input-array-is-sorted
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given a <strong>1-indexed</strong> a(...TRUNCATED) |
167
|
Medium
| ["Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find t(...TRUNCATED) | [{"hash":792140305618905326,"runtime":"234ms","solution":"class Solution:\n def twoSum(self, nums(...TRUNCATED) | "class Solution(object):\n def twoSum(self, numbers, target):\n \"\"\"\n :type numb(...TRUNCATED) | "import random\n\ndef generate_test_case():\n # Generate the length of the array based on the con(...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
twoSum
| "[{\"input\": [[2, 7, 11, 15], 9], \"expected\": [1, 2]}, {\"input\": [[2, 3, 4], 6], \"expected\": (...TRUNCATED) |
expression-add-operators
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given a string <code>num</code> that(...TRUNCATED) |
282
|
Hard
| ["Given a string num that contains only digits and an integer target, return all possibilities to in(...TRUNCATED) | [{"hash":-1923361310744562821,"runtime":"5482ms","solution":"class Solution:\n def addOperators(s(...TRUNCATED) | "class Solution(object):\n def addOperators(self, num, target):\n \"\"\"\n :type nu(...TRUNCATED) | "import random\nimport string\n\ndef generate_test_case():\n num = ''.join(random.choice(string.d(...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if sorted(outputs) == sorted(expected):\n (...TRUNCATED) |
addOperators
| "[{\"input\": [\"123\", 6], \"expected\": [\"1*2*3\", \"1+2+3\"]}, {\"input\": [\"232\", 8], \"expec(...TRUNCATED) |
sum-root-to-leaf-numbers
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>You are given the <code>root</code> (...TRUNCATED) |
129
|
Medium
| ["You are given the root of a binary tree containing digits from 0 to 9 only.\n\nEach root-to-leaf p(...TRUNCATED) | [{"hash":4060210370930641564,"runtime":"39ms","solution":"# Definition for a binary tree node.\n# cl(...TRUNCATED) | "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, val=0, le(...TRUNCATED) | "import random\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left(...TRUNCATED) |
def convert_online(case):
return case
| "def convert_offline(case):\n import lctk\n inputs, expected = case\n inputs = lctk.binaryT(...TRUNCATED) | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
sumNumbers
| "[{\"input\": [[1, 2, 3]], \"expected\": 25}, {\"input\": [[4, 9, 0, 5, 1]], \"expected\": 1026}, {\(...TRUNCATED) |
license-key-formatting
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>You are given a license key represen(...TRUNCATED) |
482
|
Easy
| ["You are given a license key represented as a string s that consists of only alphanumeric character(...TRUNCATED) | [{"hash":-3618123255579938907,"runtime":"150ms","solution":"class Solution:\n def licenseKeyForma(...TRUNCATED) | "class Solution(object):\n def licenseKeyFormatting(self, s, k):\n \"\"\"\n :type s(...TRUNCATED) | "import random\nimport string\n\ndef generate_test_case():\n length = random.randint(1, 10**3)\n (...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
licenseKeyFormatting
| "[{\"input\": [\"5F3Z-2e-9-w\", 4], \"expected\": \"5F3Z-2E9W\"}, {\"input\": [\"2-5g-3-J\", 2], \"e(...TRUNCATED) |
gas-station
| {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>There are <code>n</code> gas station(...TRUNCATED) |
134
|
Medium
| ["There are n gas stations along a circular route, where the amount of gas at the ith station is gas(...TRUNCATED) | [{"hash":-964204136414872315,"runtime":"1334ms","solution":"class Solution:\n def canCompleteCirc(...TRUNCATED) | "class Solution(object):\n def canCompleteCircuit(self, gas, cost):\n \"\"\"\n :typ(...TRUNCATED) | "import random\n\ndef generate_test_case():\n n = random.randint(1, 10**5)\n gas = [random.ran(...TRUNCATED) |
def convert_online(case):
return case
|
def convert_offline(case):
return case
| "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) |
canCompleteCircuit
| "[{\"input\": [[1, 2, 3, 4, 5], [3, 4, 5, 1, 2]], \"expected\": 3}, {\"input\": [[2, 3, 4], [3, 4, 3(...TRUNCATED) |
End of preview. Expand
in Data Studio
NewMercury
This dataset is a part of an efficiency evaluation framework for LLM-generated code. It is based on Mercury, a competitive programming benchmark, with the following improvements:
- test generation facilities and extended test suites
- corrected test generation, input conversion and solution evaluation functions
- enhanced sandbox with additional library imports and adjusted time/recursion limits
See this repository on Github for more details.
- Downloads last month
- 3